Click here to Skip to main content
14,700,158 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
The first column of a GridView is having CheckBox.
GridView is having paging of page size =5.

IThere are 12 records in a GridView. So Gridview shows 3 pages Now i check only 2 checkboxes in first page and 3 checkboxes in second page and only 1 checkbox in third page.

Now in Button click event i am writing the code
string DID= "";
 foreach (GridViewRow gvrow in gvFiles.Rows)
            CheckBox chk = new CheckBox();
            chk = (CheckBox)gvrow.FindControl("chkSelect");
            if (chk.Checked)
               if (DID== "")
DID= gvFiles.DataKeys[gvrow.RowIndex].Values["DocumentID"].ToString();
             DID= DID+ "," + gvFiles.DataKeys[gvrow.RowIndex].Values["DocumentID"].ToString();
return DID;

Only the checked rows for the first page of the grid is showing. the checked rows in the other pages of Gridview are not captured.

Can i get the code for the following.. where i can get only the checked rows in all the pages of a GridView.

Updated 14-Mar-11 22:18pm
Toniyo Jackson 15-Mar-11 3:18am
Use pre tag for code.

you are not getting the other checked records because it loads everytime you click on page numbers and the state of checked records gets lost.

you can find solution by this..


Its just like you select mails in Gmail...think about it.. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900