Best place to hold dataset between postbacks?

  • Thread starter Thread starter Gandalf
  • Start date Start date
G

Gandalf

I have a page with a datagrid that is bound initially to a dataset. As the
user changes items on the grid, I want to cache the changes until a final
submit. Ideally I wish to update the dataset on each postback and at the
end, submit the changes to the database. But where should I store the
dataset? I can put it into the viewstate, but that gets very large, or I can
put it in a session object. Which of these two is better? Are there any
other alternatives?

Thx
 
In most situations Session state would likely be the best place. Remember
to deallocate when you're done with it so it will eat a minimal amount of
memory. Even then it will take a significant amount of server memory for a
while, which will put limitations on the scalability of your app. Using
viewstate would offload some of that work to the client, but will increase
your bandwidth needs. Another option would be to use a staging table in the
database to save between each request. Of course this puts more load on
your SQL Server.
It's all about trade offs. No matter how you do it, the work has got to go
somewhere, in some tier. Pick one. How about the least used one?
 
Back
Top