Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,
I've checkbox in my gridview. My gridview page size=10,
i've selected one checkbox in page 1 and selected another checkbox
in page 2 but during this process my checkbox in page 1 was unselect.

It may be because of page index changing but hw can solve this problem??

Any solution???
Posted

It's quite simple really, all you have to do is:

Quote:
1. Loop through the grid view rows in your PageIndexChanging event
2. Find the check box in each row and see whether it's checked
3. Update the checked value in session

Refer the link for similar article:
Maintaining State of CheckBoxes While Paging in a GridView Control[^]


--Amit
 
Share this answer
 
Comments
Thanks7872 10-Jun-13 1:53am    
yes...its the good one....↑voted..!
_Amy 10-Jun-13 1:56am    
Thank you Rohan. :)
Thanks7872 10-Jun-13 1:58am    
you are welcome..!
VIP Venkatesan 10-Jun-13 5:30am    
facing error like "Specified cast is not valid" at
index = (int)GridView1.DataKeys[gvrow.RowIndex].Value;

how to solve this?
_Amy 10-Jun-13 5:33am    
Check for following:
1. Are you setting DataKeys to GridView?
2. GridView1.DataKeys[gvrow.RowIndex].Value should not be Empty String("").
--Amit
 
Share this answer
 
v2
Comments
VIP Venkatesan 10-Jun-13 5:30am    
facing an error "Specified cast is not valid" at
index = (int)GridView1.DataKeys[gvrow.RowIndex].Value;

how to solve this?
ridoy 10-Jun-13 6:38am    
Try..
int index = Convert.ToInt32(GridView1.DataKeys[gvrow.RowIndex].Value);
VIP Venkatesan 10-Jun-13 7:40am    
ya i've tried this one. but got the same error. after changed my datatype into int it works fine.. thanks for sharing the above links.. it really helpful..

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