I have one gridview with checkboxes and it contains lot of data for that reason I applied paging for gridview and displaying 8 records per page. After apply the paging in gridview if I select checkboxes in first page and moving to another page and select some checkboxes in second page after that if I come back I am unable to see the previous selected values. At that time I know one new thing that is gridview won’t maintain the state of controls during postback for that reason we need write some code to maintain the previous selected values in gridview. Before seeing the code implemention first Design your aspx pagelike this
After completion of aspx page design add the following references in code behind
After completion of adding reference write the following code in code behind
protected void Page_Load(object sender, EventArgs e)
If you observe above code I written one method to bind our gridview and written two more methods those are SaveCheckedValues and PopulateCheckedValues these two methods are used to maintain the state of selected checkbox values during paging in gridview. In SaveCheckedValues method I used Session variable to maintain the selected checkbox values after that by using this saved session values I am populating the checkbox state in PopulateCheckedValues method.