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

Posted on 2004-11-12
Last Modified: 2008-01-09
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!
Question by:MargusLehiste
    LVL 17

    Expert Comment

    You can store the dataset in Session:

    From Page1:

    Session("PassedDS") = ds

    From Page2:

    Dim ds As DataSet = Session("PassedDS")

    LVL 28

    Expert Comment

    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:

    LVL 1

    Author Comment

    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.
    LVL 28

    Assisted Solution


    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

    LVL 1

    Accepted Solution



    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

    Expert Comment

    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?

    LVL 1

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now