Dataset In Session Variable

Discussion in 'ASP .Net' started by Miro, Jan 5, 2010.

  1. Miro

    Miro Guest

    Quick question...

    I was watching a tutorial video and in that example they created a DataSet -
    filled it with some data (small amount of data).
    Then they stored it to a session variable.

    On postbacks they just kept using that dataset filled data for some
    comparisons.

    I was under the impression that was a 'nono' and it is better just to
    refetch the data?

    Or is it the norm to grab a dataset and do updates and fills on it just as
    if it was a windows app and store it into a session variable.

    Thanks,

    Miro
     
    Miro, Jan 5, 2010
    #1
    1. Advertising

  2. "Miro" <> wrote in news:e2tI5SijKHA.5520
    @TK2MSFTNGP06.phx.gbl:

    > I was under the impression that was a 'nono' and it is better just to
    > refetch the data?


    Storing in Session in ASP was really bad. It is only partially bad in
    ASP.NET. ;-)

    In general, session is not my favorite way, as you can end up screwing
    yourself if you do this on multiple pages and do not spend time
    planning. ViewState is a better option in many cases, but make sure you
    understand the Page model, or you can end up with strange results.
    ViewState can get rather large, which leads people back to Session or
    Cache.

    As for the 'nono' part, it is often easier to fetch and redisplay. But,
    if the data is manipulated a lot, however, it makes more sense to cache
    somewhere (cache, session, viewstate) rather than churning the data over
    and over again. the caching option depends mostly on your needs, but can
    go to the skill of the programming team, as well.

    Without knowing the app in question, I cannot say whether session was a
    bad idea.

    Peace and Grace,


    --
    Gregory A. Beamer (MVP)

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
     
    Gregory A. Beamer, Jan 5, 2010
    #2
    1. Advertising

  3. Miro

    Miro Guest

    Thanks for the info.

    Cheers'

    Miro

    "Gregory A. Beamer" <> wrote in message
    news:Xns9CF78188FA8A9gbworld@207.46.248.16...
    > "Miro" <> wrote in news:e2tI5SijKHA.5520
    > @TK2MSFTNGP06.phx.gbl:
    >
    >> I was under the impression that was a 'nono' and it is better just to
    >> refetch the data?

    >
    > Storing in Session in ASP was really bad. It is only partially bad in
    > ASP.NET. ;-)
    >
    > In general, session is not my favorite way, as you can end up screwing
    > yourself if you do this on multiple pages and do not spend time
    > planning. ViewState is a better option in many cases, but make sure you
    > understand the Page model, or you can end up with strange results.
    > ViewState can get rather large, which leads people back to Session or
    > Cache.
    >
    > As for the 'nono' part, it is often easier to fetch and redisplay. But,
    > if the data is manipulated a lot, however, it makes more sense to cache
    > somewhere (cache, session, viewstate) rather than churning the data over
    > and over again. the caching option depends mostly on your needs, but can
    > go to the skill of the programming team, as well.
    >
    > Without knowing the app in question, I cannot say whether session was a
    > bad idea.
    >
    > Peace and Grace,
    >
    >
    > --
    > Gregory A. Beamer (MVP)
    >
    > Twitter: @gbworld
    > Blog: http://gregorybeamer.spaces.live.com
    >
    > *******************************************
    > | Think outside the box! |
    > *******************************************
     
    Miro, Jan 5, 2010
    #3
  4. Miro

    Miro Guest

    Thanks for the info.

    Cheers'

    Miro

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Miro" <> wrote in message
    > news:...
    >
    >> I was under the impression that was a 'nono' and it is better just to
    >> refetch the data?

    >
    > As Greg has (correctly) pointed out, this sort of internal page
    > persistence is what ViewState is for.
    >
    > However, it's not *always* bad to persist data from databases in other
    > places.
    >
    > E.g. if you had an application where you needed to know information about
    > the current user, maybe email address, department, home address etc, it
    > can make sense to fetch this data once at logon time and store it as a
    > Session variable, so long as it's not too large. This prevents unnecessary
    > database queries.
    >
    > Some people (myself included) use Application memory to persist data which
    > (almost) never changes e.g. countries and their country codes, currency
    > codes, time zones etc...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Miro, Jan 5, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,839
    Chris Taylor
    Oct 31, 2003
  2. JimO

    DataSet and dataSet

    JimO, Mar 1, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    558
    Mary Chipman [MSFT]
    Mar 8, 2006
  3. John Holmes
    Replies:
    2
    Views:
    7,147
    John Holmes
    Dec 31, 2003
  4. None
    Replies:
    1
    Views:
    813
    Karl Seguin [MVP]
    Oct 24, 2006
  5. chowchho
    Replies:
    7
    Views:
    666
    Patrice
    Mar 28, 2008
Loading...

Share This Page