Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3230074
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:53:04+00:00 2026-05-17T16:53:04+00:00

While there are similar questions here, none gave a complete answer, so I am

  • 0

While there are similar questions here, none gave a complete answer, so I am posting a new one.

I have a paged grid – jqgrid – which receives data from server by ajax, N rows (10, 20 and so on, depending on the user selection) each time. There is a boolean value in the grid row model, which is transformed into a checkbox in the displayed row.

When user checks the checkbox and then navigates to the next grid page, the state of the checkbox is obviously lost. What is the best approach to save it? Neither of the possibilities that I see fully satisfies me:

I can save the ids of the selected instances into a global javascript object on checkbox click. Thus when new dataset is obtained, I can iterate through all received instances looking for already selected ones. However this can mean a lot of javascript operations and possible slowdown for the final user, if there are a lot of selected instances.

I can store the selection on the server (session, database, whatever else). This way each time the model is generated, I will populate its boolean parameter with an adequate value. However, this can mean that when the user navigates away from my page without submitting the changes and then returns back, the record states will be restored. I am not sure whether this is good. Generally, I am strongly against storing anything on the server side before user submits the form.

So, what would you choose / offer?

I am using ASP.NET MVC 2.0, C# 4.0, if that matters.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:53:04+00:00Added an answer on May 17, 2026 at 4:53 pm

    Your question is essentially about preserving state in an ajax scenario that does not involve the evil webforms viewstate.

    However, there is nothing wrong with viewstate when it is used to preserve state in the kind of scenarios you are working on (as opposed to providing a means to pretend a web page is a winform).

    So, why not go for the best of both worlds and store the values in an encrypted hidden field, a sort of lean, mean, smart man’s viewstate?

    When you request the next page of data, pass back to the server the existing “viewstate” (if any) plus the new checked items, decrypt the viewstate on the server, see what is in there and if it is relevant to the next page, add the new list of checked items, encrypt that and send the new “viewstate” back to the user.

    I haven’t done this, so it is just an idea. However, it is logically feasible, and very practical. I say I haven’t done this with a grid, but I have done it, with huge success, to design a wizard framework that works a dream.

    My wizards preserve their state whilst the user is filling in the forms and only in the final step does anything get persisted (if at all, depending on what the app requires).

    This framework is based on the wizard described in Steve Sanderson’s book, but extended to work seamlessly with or without ajax. And with a very simple API for controllers derived from my wizard controller.

    The code that makes this viewstate work is called from an OnActionExecuting method:

    protected override void OnActionExecuting(ActionExecutingContext filterContext)
    {
       var serialized = Request.Form["wizardData"];            
       if (serialized != null) // Form was posted containing serialized data
       {
          WizardData = (TModel)new MvcSerializer().Deserialize(serialized);
       }
    }
    

    And then in the ViewResult returned to the user:

    <%= Html.Serialize("wizardData", Model)%>
    

    In your case, as you are just paging data, you would need to serialize and encrypt the equivalent of the wizardData object and send this back with the JSON data to store somewhere in a hidden field.

    This is a bit vague, as a wizard is a not a grid of paged data. But the principles (essentially, roll your own viewstate) do apply to both scenarios.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found similar questions asked here but there weren't answers to my satisfaction. So
As comment to one of the questions here a commenter wrote (emphasis mine): ...
While there are 100 ways to solve the conversion problem, I am focusing on
I am building a multithreaded system that works like this: While there are entities:
What are some key UI design tips that every developer should know? While there
I've switch from VB.NET to C# several months ago, while there are a lot
On linux, I am opening a pseudo tty on the master side. While there
While it's my understanding that there's no fundamental reason a program written for 32-bit
Is there an easy way of using the RegularExpressionValidator control while ignoring white space?
while writing a custom attribute in C# i was wondering if there are any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.