I have a GridView located in an UpdatePanel on my webpage. To take actions against checked rows in the GridView, I have a method that first determines if at least one row is checked. Sometimes it works and sometimes it doesn't. Typically the first time I check any number of rows, it returns false. Then I recheck the rows again and it returns true and the actions begin. After that is complete, I call GridView.Databind() to refresh the data. At that time the evolution begins again, I have to check the rows twice for them to be captured in code as True.
int i = 0; foreach (GridViewRow row in GridView3.Rows) { if (row.RowType == DataControlRowType.DataRow) { CheckBox check = row.FindControl("CheckBox1") as CheckBox; if (check.Checked) { i++; } } } if (i != 0) { //do something }