http://aspalliance.com/774
Title: Repopulating checkboxes in GridView solution
Name: Anonymous
Date: 8/13/2006 8:30:45 PM
Comment:
This is a great solution! However, when I first tested I get the same problem as everyone where the checkboxes get reset after every page changed. In order to solve this problem, you need to add DataBound event to repopulate the checkboxes states. Below is the solution:
protected void GridView1_DataBound(Object sender, EventArgs e)
{
RePopulateValues();
}
protected void GridView1_PageIndexChanging(Object sender, GridViewPageEventArgs e)
{
RememberOldValues();
}
Note: This is done in .Net 2.0 and the reason the author code doesn't work is because the databound event is called after pageindexchanging and pageindexchanged and therefore it clears the checkboxes states.