Click here to Skip to main content
15,917,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anyone help me to get the value of the checkbox from the nestedgrid?
I have the grid inside the grid, in the child grid I have a checkbox while I am trying to get the value of the checkbox to insert it into database I am not getting the value. Please help me to get the value.

XML
                <asp:GridView ID="HeaderCheckGv" runat="server" AutoGenerateColumns="False" OnRowDataBound="HeaderCheckGv_RowDataBound">
                    <columns>
                        <asp:BoundField DataField="POLICY_MAIN_ID" />
                        <asp:BoundField DataField="POLICY_ID"  />
                        <asp:BoundField DataField="POLICY_VALUE"  />
                        <asp:TemplateField >
                            <itemtemplate>
                                <asp:Label ID="GroupNameLbl" runat="server" Text='<%# Eval("POLICY_NAME")%>'>
                                <asp:GridView ID="ChildCheckGv" runat="server" AutoGenerateColumns="False" OnRowDataBound="ChildCheckGv_RowDataBound">
                                    <columns>
                                        <asp:BoundField DataField="POLICY_MAIN_ID"  />
                                        <asp:BoundField DataField="POLICY_ID" />
                                        <asp:BoundField DataField="POLICY_NAME" />
                                        <asp:TemplateField HeaderText="GeneralPolicy">
                                        <itemtemplate>
                                                <asp:CheckBox ID="GeneralPolicyCb" runat="server" />
</itemtemplate>                                     
                                    </columns>                               
                            </itemtemplate>                        
                    </columns>
                </columns></itemtemplate></columns>

C#
objdc.NameofFormCHK=string.Empty;
               for(int i=0;i<headercheckgv.rows.count;i++)>
                {
                    objdc.NameofFormCHK+=((CheckBox)HeaderCheckGv.Rows[i].Cells[0].FindControl("GeneralPolicyCb")).checked;
             }
Posted
Updated 16-Nov-10 5:32am
v4

1 solution

hi,

First u need to get the gridview control id using find control,
Gridview gvChild=((Gridview)HeaderCheckGv.Rows[i].Cells[0].FindControl("ChildCheckGv"));


then u get the checkbox id using gvChild,
objdc.NameofFormCHK+=((CheckBox)gvChild.Rows[i].Cells[0].FindControl("GeneralPolicyCb")).checked;
 
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