Which checkboxes changed in a GridView - c#

I have a GridView where one column is a checkbox, like this
<ecc:ExportableGridView ID="dgTrxAvailable" runat="server" AutoGenerateColumns="False"
CellPadding="0" FixedColumns="" OnRowDataBound="dgTrxAvailable_OnRowDataBound"
PageIndex="1" Width="100%">
<Columns>
<asp:TemplateField HeaderText="N°" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblCounter" runat="server" ReadOnly="True" CssClass="txtGrid t3 c3"
Text='<%# Container.DataItemIndex + 1 %>' />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="3%" CssClass="t3" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="TrX" Visible="false" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="txt_id_transaccion" runat="server" ReadOnly="True" CssClass="txtGrid t3 c3"
Text='<%# Bind("id_transaccion") %>' />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="10%" CssClass="t3" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Include">
<HeaderTemplate>
<asp:Label ID="Label2" runat="server" Text="Incluir" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="RuleDate" runat="server" Checked='<%#Eval("RuleDate") %>'/>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="3%" CssClass="t3" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
</ecc:ExportableGridView>
I want to know, of a group of n rows, which checkboxes changed, doesnt't matter if they were unchecked/checked.
What I tried is to add a class to the checkbox like this:
$('input[type=checkbox]').change(function () {
$(this).addClass("Selected");
});
And ask in the backend:
protected void btnApply_Click(object sender, EventArgs e)
{
foreach (GridViewRow item in dgTrxAvailable.Rows)
{
if ((item.FindControl("RuleDate") as CheckBox).CssClass == "Selected")
{
//Logic here
}
}
}
but the value of CssClass is empty and I think there is a better solution to this without using magic strings, etc.
Any ideas?.

Related

I have a group of radio button in each row of the gridview. Base on the user selection of the radio button, I would like to update the database

I have a group of radio button in each row of the gridview. Base on the user selection of the radio button, I would like to update the database, when user click the Submit Button on the page. How do I reference those radio button in the code page?
source code
<asp:GridView ID="gvActList" runat="server" Font-Size="Smaller" Width="100%" CssClass="tableStyle"
EmptyDataText="No Data Found" AllowPaging="false"
CellPadding="4" AutoGenerateColumns="False" autopostback="true">
<FooterStyle Font-Bold="True" CssClass="tablefooter" />
<RowStyle CssClass="tableRow1" />
<SelectedRowStyle Font-Bold="True" CssClass="tableRowHighlight" />
<HeaderStyle Font-Bold="True" CssClass="tableHeader" Font-Size="9px" />
<Columns>
<asp:TemplateField HeaderText="TM Activity Code" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%" HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lbl_Activity_Code" runat="server" Visible="true" Text='<%# Bind("ACTIVITY_CODE") %>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="19%" HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lbl_ACTDESC" runat="server" Text='<%# Bind("ACTIVITY_DESC") %>' Visible="true"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="User Details" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lbl_User_Details" runat="server" Text='<%# Bind("CREATED_BY") %>' Visible="true"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Type" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lbl_PROMO_TYPE" runat="server" Text='<%# Bind("PROMO_TYPE") %>' Visible="true"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Category" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lblCatgDescription" runat="server" Text='<%# Bind("CATEGORY_CODE") %>'
Visible="true"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date Range" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lblACTIVEFROM" runat="server" Text='<%# Bind("ACTIVE_FROM") %>' Visible="true"></asp:Label>  To  
<asp:Label ID="lblACTIVETO" runat="server" Text='<%# Bind("ACTIVE_TO") %>' Visible="true"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Activity Type" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lbl_Actvity_Type" runat="server" Text='<%# Bind("ACTIVITY_TYPE") %>' Visible="true"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Current Status" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lbl_Current_Status" runat="server" Text='<%# Bind("status") %>' Visible="true"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="View Details" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<itemstyle width="5%" />
<asp:LinkButton CssClass="l_link" Text="View" ID="lnkView" runat="server" ToolTip="View" /></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-HorizontalAlign="Center">
<HeaderTemplate>
<asp:Label ID="lblCap" Text="Confirm" runat="server"></asp:Label></HeaderTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<itemstyle width="1%" font-size="2px" horizontalalign="Center" />
<table style="text-align: Center; vertical-align: text-top;">
<tr>
<td style="width: 98%;">
<asp:RadioButton ID="rdYes" runat="server" Text="Yes" GroupName="CH"></asp:RadioButton></td>
</tr>
<tr>
<td style="width: 98%;">
<asp:RadioButton ID="rdNo" runat="server" Text="No" GroupName="CH"></asp:RadioButton></td>
</tr>
<tr>
<td style="width: 98%;">
<asp:RadioButton ID="rdNone" runat="server" Text="None" GroupName="CH"></asp:RadioButton></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle CssClass="tableRowHighlight" />
<RowStyle CssClass="odd_tb" />
<PagerStyle CssClass="foot_tbl" />
<AlternatingRowStyle CssClass="even_tb" />
<PagerSettings Mode="NextPreviousFirstLast" />
</asp:GridView>
pls help me
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (gvActList.Rows.Count > 0)
{
foreach (GridViewRow row in gvActList.Rows)
{
RadioButton rdYes= (RadioButton)row.FindControl("rdYes");
RadioButton rdNo = (RadioButton)row.FindControl("rdNo");
RadioButton rdNone = (RadioButton)row.FindControl("rdNone");
if (rdYes != null && rdNo != null && rdNone != null)
{
if (rdYes.Checked == true)
{
//some code
}
else if (rdNo.Checked == true)
{
//some code
}
}
}
}
}
You can use above code on the button click. One suggestion is to use RadiobuttonList instead of RadioButton so that it will reduce the code.
on button click declare a gridview row. make a for loop and find the radio button in each row and other controls whose value you want to update. check the conditions as per your requirement and update accordingly

C# - Issue with RenderControl , 'RegisterForEventValidation can only be called during Render()'

I need do get Html of GridView and send email.
My GridView Design is mentioned as below
<div id="DivEmail" class="clear">
<asp:Repeater ID="rpt1" runat="server" OnItemDataBound="rpt1_ItemDataBound">
<ItemTemplate>
<asp:HiddenField ID="TypeID" runat="server" Value='<%# Eval("TypeID") %>' />
<div id='Handle<%# Eval("TypeName")%>' class="ulheader" >
<asp:Label ID="lblType" runat="server" Text='<%# Eval("TypeName")%>' ></asp:Label>
</div>
<div id="Reuslt<%# Eval("TypeName")%>">
<asp:GridView ID="grvReport" runat="server" Width="100%" BorderColor="#e4e4e4" border="0" Style="border-collapse: collapse;" ShowHeader="true" CellPadding="5" CellSpacing="0" AutoGenerateColumns="false" EmptyDataText="No Results Found" AllowPaging="false" AllowSorting="false" CssClass="grid grid-iq" BackColor="#FFFFFF">
<Columns>
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="thumb" Width="100px" Height="100px" runat="server" ImageUrl='<%# Eval("ImageUrl") %>'
ImageAlign="Middle" />
</ItemTemplate>
ItemStyle CssClass="center" Height="20px" />
<HeaderStyle CssClass="grid-th center" Width="100px" VerticalAlign="Top" />
</asp:TemplateField>
<asp:BoundField DataField="Title" HeaderText="Title">
<HeaderStyle Height="20px" Width="20%" CssClass="grid-th-left" VerticalAlign="Top" />
<ItemStyle CssClass="left"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Description" HeaderText="Description">
<HeaderStyle Height="20px" Width="28%" CssClass="grid-th-left" VerticalAlign="Top" />
<ItemStyle CssClass="left"></ItemStyle>
</asp:BoundField>
<asp:TemplateField ShowHeader="false" HeaderText="View">
<ItemTemplate>
<asp:LinkButton ID="lbtnLink" runat="server" CommandArgument='<%# Bind("ID") %>'
OnCommand="lbtnView_OnCommand" Text="View"></asp:LinkButton>
</ItemTemplate>
<ItemStyle CssClass="center" Height="20px" />
<HeaderStyle CssClass="grid-th center" Width="9%" VerticalAlign="Top" />
</asp:TemplateField>
</Columns>
<HeaderStyle CssClass="grid-th" Height="10px" HorizontalAlign="Center" VerticalAlign="Top"></HeaderStyle>
</asp:GridView>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
To grab Html of server control , I use below code
protected void btnOK_Click(object sender, EventArgs e)
{
var sb = new StringBuilder();
DivEmail.RenderControl(new HtmlTextWriter(new StringWriter(sb)));
EmailContent += sb.ToString();
}
public override void VerifyRenderingInServerForm(Control control)
{
/* Confirms that an HtmlForm control is rendered for the specified ASP.NET
server control at run time. */
}
By doing such , I m getting Exception
RegisterForEventValidation can only be called during Render()
I googled a bit on the issue, results says to set EnableEventValidation="false" in #page directive. but I can not use this solution.
Can anybody help me on this to solve??

how to get the delete row value if I wanna to delete it in gridview (web application)

when i have a gridview, after the user press the delete button, i will like to know that the particular row data in this case, how i get the particular row data?
Sample gridview:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" DataKeyNames="addCartID"
BackColor="White"
BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3"
CellSpacing="1" GridLines="None" OnRowDeleted="Delete_Event">
<Columns>
<asp:CommandField ShowDeleteButton="True" />
<asp:TemplateField HeaderText="addCartID" InsertVisible="False"
SortExpression="addCartID">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("addCartID") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("addCartID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="productID" SortExpression="productID">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("productID") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("productID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="custID" SortExpression="custID">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("custID") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("custID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="seatOrderID" SortExpression="seatOrderID">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("seatOrderID") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("seatOrderID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#594B9C" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#33276A" />
</asp:GridView>
Here is the c# code i wanna get the delete value, after user click delete i wish to update something based on the seatOrderID deleted, how do i get it? tq~~
protected void updateBack()
{
Response.Write(I want to get the deleted seatOrderID here!!!!!);
}
Using this code, you can fetch the ID in the RowDeleting event:
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
GridViewRow gvr = (GridViewRow)GridView1.Rows[e.RowIndex];
string id = String.Empty;
Label lbl = (gvr.FindControl("Label1") as Label)
if (lbl != null)
{
id = lbl.Text;
}
}
You can fetch any control in the row, using the FindControl() method.

How to bind hovermenuextender control to a row with multiple columns in a dynamic gridview?

I wish to attach a hovermenu pop up to rows of a gridview which is dynamically populated from a datasource. I tried to set TargetcontrolId property of hovermenuextender control to row unique Id on occurence of rowdatabound event. But rather than appearing on the right side of each row, pop up is appearing on the right side of header row. Can somebody help me resolve this problem? I used below code for the same
CodeBehind:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HoverMenuExtender hoverMenu =(HoverMenuExtender)e.Row.FindControl("hme2");
if (hoverMenu != null)
{
hoverMenu.TargetControlID = hoverMenu.Parent.Parent.UniqueID;
}
}
}
}
Aspx page:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" ShowFooter="false" ShowHeader="false"
OnRowEditing="GridView1_RowEditing" OnRowCommand="GridView1_RowCommand" OnRowUpdating="GridView1_RowUpdating"
GridLines="None" OnRowDataBound="GridView1_RowDataBound">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText ="Talk Title">
<ItemTemplate>
<asp:Label Font-Bold="true" ID="lbltalktitle" runat="server" Text='<%#Eval("Talk_Title") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText ="Brand">
<ItemTemplate>
<asp:Label ID="lblBrand" runat="server" Text='<%# Eval("Brand") %>' /></td>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText ="Franchise">
<ItemTemplate>
<asp:Label ID="lblFranchise" runat="server" Text='<%# Eval("Franchise") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText ="programmetype">
<ItemTemplate>
<asp:Label ID="lblprg" runat="server" Text='<%# Eval("programmetype") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText ="programmetype">
<ItemTemplate>
<asp:Label ID="lblsaledforce" runat="server" Text='<%# Eval("salesforce") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText ="Start_Date">
<ItemTemplate>
<asp:Label ID="lblstartdate" runat="server" Text='<%# Eval("Start_Date") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText ="End_Date">
<ItemTemplate>
<asp:Label ID="lblenddate" runat="server" Text='<%# Eval("End_Date") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<cc1:HoverMenuExtender ID="hme2" runat="server" TargetControlID="lblenddate"
PopupControlID="PopupMenuX" HoverCssClass="popupHover" PopupPosition="Right"/>
<asp:Panel CssClass="popupMenu" ID="PopupMenuX" runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit" Text="Edit" /><br />
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete" Text="Delete" />
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle ForeColor="Black" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#594B9C" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#33276A" />
</asp:GridView>
protected void gv_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
AjaxControlToolkit.HoverMenuExtender ajxhovermenu = (AjaxControlToolkit.HoverMenuExtender)e.Row.FindControl("ahm_1");
e.Row.ID = e.Row.RowIndex.ToString();
ajxhovermenu.TargetControlID = e.Row.ID;
}
}
Give TargetControlID of the HoverMenuExtender in RowCreated event of GridView and set it as the RowID

Nested grid edit doesn't work

I'm stuck on this problem where I have grid within grid where the nested grid is editable. I can't get the edit working. What's complicates things is that the nested grid is inside a modal popup extender.
It works to the point where I click on the edit button. Then the EmptyDataText property kicks in with the message. If I click on it second time the grid opens in edit mode but the update/cancel buttons don't work. The cancel button when click displays the EmptyDataText property.
Another issue is that this nested grid doesn't use a object data source so I'm going to have to all the updating and deleting in the code file. Not sure now to do that either.
I would like some advice as to how to make this corrected. Here is the code:
<asp:GridView ID="gvForum" runat="server" DataSourceID="odsForumApproval" DataKeyNames="id" Width="200px"
RepeatColumns="1" DataKeyField="id" CssClass="gridview"
AutoGenerateColumns="False" GridLines="None" OnSelectedIndexChanged="_OnCommand">
<AlternatingRowStyle CssClass="altbgcolor" />
<Columns>
<asp:TemplateField >
<ItemTemplate>
<asp:Label runat="server" ID="lblTitle" Text='<%# Bind("Title") %>' />
<asp:Panel id="div" runat="server" align="center" class="confirm" style="display:none" >
<asp:GridView runat="server" ID="gvForumDetail" AutoGenerateColumns="False" DataKeyNames="id"
AllowPaging='true' CssClass="gridview"
AllowSorting="true" PageSize="5" CellPadding="5" OnRowEditing="gvForumDetail_OnRowEditing"
OnRowCancelingEdit="gvForumDetail_CancelRecord" >
<AlternatingRowStyle CssClass="altbgcolor" />
<RowStyle VerticalAlign="Top" HorizontalAlign="Left" />
<HeaderStyle CssClass="greenbar" ForeColor="White" /> <Columns>
<asp:BoundField DataField="id" ReadOnly="true" Visible="false" />
<asp:TemplateField HeaderText="Title">
<ItemTemplate>
<asp:Label runat="server" ID="lblTraining" Text='<%# Bind("title") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtTraining" Text='<%# Bind("title") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Post Message">
<ItemTemplate>
<asp:Label runat="server" ID="lblCompletionDate" Width="250" Text='<%# Bind("description") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtDescription" Text='<%# Bind("description") %>' TextMode="MultiLine" Rows="5" Width="250" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Posted By">
<ItemTemplate>
<asp:Label runat="server" ID="lblRecurence" Text='<%# Bind("MemberName") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Posted Date">
<ItemTemplate>
<asp:Label runat="server" ID="lblNotes" Text='<%# Eval("itemdate", "{0:d}") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox runat="server" ID="cbxApproved" Text='<%# Bind("approved") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowCancelButton="true" ShowEditButton="true" ShowDeleteButton="true" />
</Columns>
</asp:GridView>
<br />
<Club:RolloverLink ID="btnClose" runat="server" Text="Close" />
</asp:Panel>
<ajaxToolKit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="lblTitle"
PopupControlID="div"
CancelControlID="btnClose"
BackgroundCssClass="modalBackground" />
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowSelectButton="True" />
</Columns>
Code behind:
public void _OnCommand(object sender, EventArgs e)
{
ObjectDataSource ods = new ObjectDataSource();
ods.ID = "ods_ForumDetail";
ods.EnableViewState = true;
ods.TypeName = "ForumApproval";
ods.SelectMethod = "GetForumById";
string id = "";
int rowIndex = gvForum.SelectedIndex;
id = gvForum.DataKeys[rowIndex].Value.ToString();
ods.SelectParameters.Add("id", System.TypeCode.Int32, id);
var ModalPopupExtender1 = (ModalPopupExtender)(gvForum.SelectedRow.FindControl("ModalPopupExtender1"));
ModalPopupExtender1.Show();
var gvForumDetail = (GridView)(gvForum.SelectedRow.FindControl("gvForumDetail"));
gvForumDetail.DataSource = ods;
gvForumDetail.DataBind();
}
protected void gvForumDetail_OnRowEditing(Object sender, GridViewEditEventArgs e)
{
var ModalPopupExtender1 = (ModalPopupExtender)(gvForum.SelectedRow.FindControl("ModalPopupExtender1"));
ModalPopupExtender1.Show();
var gvForumDetail = (GridView)(gvForum.SelectedRow.FindControl("gvForumDetail"));
gvForumDetail.EditIndex = e.NewEditIndex;
gvForumDetail.DataBind();
}
protected void gvForumDetail_CancelRecord(object sender, GridViewCancelEditEventArgs e)
{
var ModalPopupExtender1 = (ModalPopupExtender)(gvForum.SelectedRow.FindControl("ModalPopupExtender1"));
ModalPopupExtender1.Show();
var gvForumDetail = (GridView)(gvForum.SelectedRow.FindControl("gvForumDetail"));
gvForumDetail.EditIndex = -1;
gvForumDetail.DataBind();
}
I will try to answer part of your question, updating and deleting the code. you need to take advantage of the "onrowcommand" for the inner gridview (OnRowCommand).

Categories