I have a problem. I'm using gridview to display data. when gridview display the data, i allow user to choose the data by checked the check box then user will see how many check box that they checked below the gridview. if user only check in 1 page of gridview
thats ok it show total of checked checkbox in that page. but problem comes up when user move to second page of gridview, the total will start again from 0 which means i lost the total of the checkbox from the first page.
That's actually I want to ask. How to store the count of checked items. Because I can keep the check box checked eventhough the user move to another page.
you can do it either from server side and client side .If you are using server side .you can save the count in sessionstate or viewstate.
You have to traverse the gridview for the total no of selected items .you can also do it from client side using jquery which is the best way avoiding postbacks .check this
andre127
Member
38 Points
30 Posts
How to count checked checkbox in gridview
Mar 23, 2012 08:33 AM|LINK
Hi all,
I have a problem. I'm using gridview to display data. when gridview display the data, i allow user to choose the data by checked the check box then user will see how many check box that they checked below the gridview. if user only check in 1 page of gridview thats ok it show total of checked checkbox in that page. but problem comes up when user move to second page of gridview, the total will start again from 0 which means i lost the total of the checkbox from the first page.
anyone know how to solve it?
Thanks alot.
Andre
ItsSunny
Contributor
2163 Points
676 Posts
Re: How to count checked checkbox in gridview
Mar 23, 2012 08:35 AM|LINK
How are you storing the count of checked items??
Arun Sunny.
andre127
Member
38 Points
30 Posts
Re: How to count checked checkbox in gridview
Mar 23, 2012 08:54 AM|LINK
That's actually I want to ask. How to store the count of checked items. Because I can keep the check box checked eventhough the user move to another page.
Any suggestion?
Thanks alot
Andre
ItsSunny
Contributor
2163 Points
676 Posts
Re: How to count checked checkbox in gridview
Mar 23, 2012 09:21 AM|LINK
you can do it either from server side and client side .If you are using server side .you can save the count in sessionstate or viewstate.
You have to traverse the gridview for the total no of selected items .you can also do it from client side using jquery which is the best way avoiding postbacks .check this
http://www.dotnetcurry.com/ShowArticle.aspx?ID=662
Arun Sunny.