views:

424

answers:

1

I have a repeater that displays data from database, each item has a checkbox that are used to "mark" items for deletion and etc. (there is no item in database for chekbox!).

Because I use pagination (on data access and presentation levels), there is no way to preserve checkboxes values between page movements.

How can I solve this issue?

A: 

The way I've solved this in the past is to have a handler on the checkbox that does some AJAX back to the server to store the state of that checkbox when it is toggled. This information gets stored in the user's session. During paging, I check the state for each checkbox and set it appropriately as the page is rendered. Any actions that depend on the state of the checkbox use the information from the session. Once the action is completed, I remove the state from the session. You'll also have to figure out how you want to handle this with respect to page navigation as well.

tvanfosson
What do you mean by " You'll also have to figure out how you want to handle this with respect to page navigation as well."?
How do you want to handle the check box state when the user navigates to another page? Should the state persist between different pages or should it reset? If you persist it, you'll need to check state when you do the initial page load. If you don't want it persisted, then you'll need to check on initial page load and remove any pre-existing data so that it matches what is rendered.
tvanfosson
...when you come back to the page again, I mean.
tvanfosson
Onr more qusstion: why it's not good to mantain their state at server side(after moving to another page or so) ?Why i should Use javascript?
You could put all of this into viewstate and have the checkboxes do a full postback, but IMO that's a pretty poor user experience and just as hard. You might try storing the state in a cookie, but I'd still go with javascript.
tvanfosson