how can i get the checkbox state of my checkboxes inside a gridview?
i have programmatically added them like so,
foreach (GridViewRow gvr in GridView1.Rows)
{
tbCell = new TableCell();
cbGV = new CheckBox();
tbCell.Controls.Add(cbGV);
gvr.Cells.Add(tbCell);
{
Normally i would get the state of the checkboxes like so(below) when they are inside an itemtemplate, but this is not working, so any ideas guys ??
foreach (GridViewRow getRowItems in GridView1.Rows)
{
chkBox = (CheckBox)(getRowItems.Cells[0].FindControl("cbGV"));
if(chkBox.Checked == false)
{
chkBox.Checked = true;
}
}
Try to add checkbox like this , i.e. as template column and than try to search this will also work rather than adding checkbox dynamically
this is not working because you forgot to give id to element
try to give id as above and than try to find checkbox in row