<asp:Panel CssClass="grid" ID="pnlCust" runat="server"> <asp:GridView ID="gvCustomers" AutoGenerateColumns="False" DataKeyNames="EmpID" runat="server" ShowHeader="true" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical"> <AlternatingRowStyle BackColor="White" /> <Columns> <asp:TemplateField> <ItemTemplate> <%--<asp:Image ID="imgCollapsible" CssClass="first" ImageUrl="~/Assets/img/plus.png" Style="margin-right: 5px;" runat="server" /><span class="header"> <%#Eval("EmpID")%> : <%#Eval("empname")%>--%> <asp:RadioButton ID="rdbtn" runat="server" onclick="RadioCheck(this);" OnCheckedChanged="radio_changed" Text='<%# Bind("EmpID") %>' AutoPostBack="true"></asp:RadioButton> <asp:GridView AutoGenerateColumns="false" CssClass="grid" ID="gvOrders" runat="server" PageSize="1" ShowHeader="true" EnableViewState="false" DataKeyNames="EmpID" OnPageIndexChanging="gvOrders_PageIndexChanging"> <RowStyle CssClass="row" /> <AlternatingRowStyle CssClass="altrow" /> <Columns> <asp:BoundField HeaderText="Employee Id" DataField="EmpID"> <ItemStyle HorizontalAlign="Center" Width="100px" /> </asp:BoundField> <asp:TemplateField ItemStyle-CssClass="rownum"> <ItemTemplate> <%# Container.DataItemIndex + 1 %> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderStyle-BackColor="#EFF1F1" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="25" HeaderStyle-Width="50" ItemStyle-Width="50"> <HeaderTemplate> <input id="chkBoxAll" type="checkbox" onclick="checkAllBoxes()" /> </HeaderTemplate> <ItemTemplate> <asp:CheckBox ID="chkBoxChild" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="PayPeriodNumber" HeaderText="PayPeriod" HeaderStyle-BackColor="#EFF1F1" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="80" ItemStyle-Width="80"> </asp:BoundField> <asp:BoundField DataField="PayRollYear" HeaderText="Payroll Year" HeaderStyle-BackColor="#EFF1F1" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="100" ItemStyle-Width="100"> </asp:BoundField> <asp:BoundField DataField="PaymentDate" HeaderText="Payment Date" HeaderStyle-BackColor="#EFF1F1" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="110" ItemStyle-Width="110"> </asp:BoundField> </Columns> </asp:GridView> </ItemTemplate> </asp:TemplateField> </Columns> <FooterStyle BackColor="#CCCC99" /> <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" /> <RowStyle BackColor="#F7F7DE" /> <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /> <SortedAscendingCellStyle BackColor="#FBFBF2" /> <SortedAscendingHeaderStyle BackColor="#848384" /> <SortedDescendingCellStyle BackColor="#EAEAD3" /> <SortedDescendingHeaderStyle BackColor="#575357" /> </asp:GridView> </asp:Panel> <asp:Button ID="btn" runat="server" Text="Delete" onclick="btn_Click" />
Sample Images http://i.stack.imgur.com/ZM96f.jpg http://i.stack.imgur.com/ULWTM.jpg
protected void btn_Click(object sender, EventArgs e) { foreach (GridViewRow gvRow1 in gvCustomers.Rows) { GridView gv = (GridView)gvRow1.FindControl("gvOrders"); foreach (GridViewRow gvrow in gv.Rows) { CheckBox chkBoxChild = (CheckBox)gvrow.FindControl("chkBoxChild"); if (chkBoxChild.Checked) { } } } }
Unable to execute my condition when I select a check box and running the code. Any help please. Also how can I work out Select All check box scenario in the child grid view.
EnableViewState="true"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)