Where to store a dataset (confused of cache, session, viewstate)?

Hey created a .xsd (strongly typed) dataset.
User inserts to this ds info he likes -
lets say its an order entry form - so each user should see their data and only when they are in that page.

Currently i stored this dataset in CACHE object.
But is that the correct place to store it
(I think "OLD" Session Object would be too slow, but VIEWSTATE ?)

Suggestions and thoughts appreciated!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can store the dataset in Session:

From Page1:

Session("PassedDS") = ds

From Page2:

Dim ds As DataSet = Session("PassedDS")

Hi MargusLehiste,

i think viewstate is a better choice if you want the dataset to be accessible only within this page, but take a look at these articles for state management:

MargusLehisteAuthor Commented:
MMarinov - thank you for your reply,

so do you think that in my case I should replace Cache with viewstate ?

AerosSaga - as I understand Application and Session variables put unnecessary overhead to server.
In my case - you are correct the dataset must be private for each user - however - I do not require access to this dataset from another page.
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.


Yes i think so, because the viestate is on the client ( e.g. accessible only for the user and not overhead the server ) and it is active only for the current page



you should store the Dataset in Session .but not in Cache because cache make a single copy of cache variable on the server,If unfortunatily two users access the page at the
same time then may be one can view the data entered by other because there will be only one cache variable on the server,and this cache object will be sharable.

If still you want to use Cache Object then make the cache object Unique by adding the SessionId like:

Cache["VariableName"+Session.SessionID] = AnyValue;

Because you also want that the dataset must be private for each user so you should only use the Session.

Atul Khare

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hi ,

I also have a similar issue.In my case the dataset is bound to a grid with heavy data.
I have felt using Viewstate has made the page slow.Any suggestions please?

MargusLehisteAuthor Commented:
Madhu - I think cache is the best way to go.
Viewstate puts a heavy load on client, Session and Application objects are OLD - and therefore not very efficient.
Ive been using Cache["VariableName"+Session.SessionID] and its been pretty OK.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.