Click here to Skip to main content
15,887,892 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have done a scenario as follows, I am having a grid view which is having another grid view as Item template of that grid view. Initially I binded a radio button and the required fields from the database. When ever user selects a radio button I will show the corresponding details in another gridi vew. This grid view has some necessary fields with check boxes. When I select a check box and click on a button out side the grid view I am unable to execute the required that was written

XML
<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" />


VB
Sample Images

http://i.stack.imgur.com/ZM96f.jpg

http://i.stack.imgur.com/ULWTM.jpg



Code for delete button

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)
                {

                }
            }
        }
    }


SQL
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.
Posted
Comments
Mohamed Mitwalli 4-Apr-12 9:17am    
so the problem because you can't Find checkbox isn't ?

1 solution

By making
EnableViewState="true"
for child grid view I got the required
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900