checkbox checked event not working
-
foreach (GridViewRow rw in this.grdEmpSearch.Rows) { ChkBox =(CheckBox(rw.Cells[0].FindControl("chk")); if (ChkBox.Checked) { chkCount++; } } i wrote the above code to check whether the checkbox inside a grid is checked or not but although the checkbox is not checked the above code is returning checked true is all the cases....
-
foreach (GridViewRow rw in this.grdEmpSearch.Rows) { ChkBox =(CheckBox(rw.Cells[0].FindControl("chk")); if (ChkBox.Checked) { chkCount++; } } i wrote the above code to check whether the checkbox inside a grid is checked or not but although the checkbox is not checked the above code is returning checked true is all the cases....
Use this
int checkedCount = 0;
foreach (GridViewRow row in gvData.Rows)
{
bool result = ((CheckBox)row.FindControl("CheckBox1")).Checked;
if (result)
{
return true;
}
else
{
return false;
}
}Gaurav Dudeja http://www.gdinfotechindia.com
Dont be afraid of changing your life to better !