Tuesday, July 14, 2009

Maintaining state of checkbox's in gridview using ASP.net, C#?

I have a gridview in which I have a field with checkbox and when we select checkbox with id 1,3,6 then this values store in database in format 1-3-6.


But I want to retrive this vakue if user again entered this checkboxes with id 1-3-6 should already checked.


Thks looking for reply.


ASP.net, C#

Maintaining state of checkbox's in gridview using ASP.net, C#?
Don't store the row index of checkbox in gridview. You have to bind the Datakey of GridView as a unique of the values retrived from the database. Then save that unique value for checkboxes instead of 1,3,6.





When you bind the GridView at page load run a for loop for each row of GridView and change the checkbox state by matching the datakey of each row.





For more information on GridView Controls with different ItemTemplate controls like LinkButton/ checkboxes you can learn from:


No comments:

Post a Comment