hunterlondon
New Member
i have a grid as \[code\] <Columns> <asp:TemplateField HeaderStyle-Width="20px"> <ItemTemplate> <asp:CheckBox ID="ChkSelect" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Id" Visible="false"> <ItemTemplate> <asp:Label ID="LbLId" runat="server" Text='<%# Bind("ID") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:Label ID="LblId" runat="server" Text='<%# Bind("ID") %>'></asp:Label> </EditItemTemplate> <ItemStyle HorizontalAlign="Center" Width="20%" /> </asp:TemplateField>\[/code\]i want to retrieve the \[code\]ID\[/code\] of a Checkbox which is checked. I have tried implementing this code, as\[code\] foreach (GridViewRow row in GvDDlToken.Rows) { CheckBox chk = row.Cells[0].Controls[0] as CheckBox; if (chk != null && chk.Checked) { string id = "," + row.Cells[1].Text; } } \[/code\]but at \[code\]Checkbox chk\[/code\] the value comes as null, no object reference has been made. what possible error i am doing? Thanks for any assistance.