Q: Questions about ViewState versus Session.

Discussion in 'ASP .Net' started by Sky, Jan 30, 2004.

  1. Sky

    Sky Guest

    Although I've been using C# for the last month or so, and accepting out of
    blind faith the ViewState, I do have some nagging questions about it... can
    you help verify the following statements?

    Application is across all sessions.
    Session is across all pages.
    ViewState is sort of like Session, but for only one page. <-- Correct
    statement?

    Session is stored between page requests, somewhere in mem or IIS files --
    but can be rerouted to DB.
    ViewState is sent to Client and returned on every post <-- Correct
    statement?

    If you load a DataSet.Table of 10 columns, 10 rows, and Bind it to a
    DataGrid
    you are sending to the Client 10x10 html cells of a table -- PLUS in the
    ViewState 10x10 values encrypted. <--Correct statement?

    If you load a DataSet.Table of 10 columns, 10 rows, and Bind it to a
    DataGrid
    but hide 7 columns you are sending to the Client 3x10 html cells of a
    table -- PLUS in the ViewState 10x10 values encrypted. <--Correct statement?

    Therefore, if you load a DataTable with 10 columns, 1000 rows, Bind it to a
    DataGrid, but put Paging on 10 per page...
    I am sending 10x10 html cells to the client -- PLUS 10x1000 cells in the
    ViewState?????


    If I DataBind a DataTable to a grid on page_load, I don't have to rebind it
    again until I update the database, and have to repick up the new DataSet <-
    Correct?


    Any other comments you may have as to what it is, and "how to think of it"?

    Thank you so much,
    Sky
    Sky, Jan 30, 2004
    #1
    1. Advertising

  2. Sky

    Teemu Keiski Guest

    Re: Questions about ViewState versus Session.

    Hi,

    first off you might want to take a look at this article:

    ViewState: All You Wanted To Know
    http://aspalliance.com/135

    Well,

    -ViewState is page-specific
    -By default ViewState is roundtripped to the client, but can also be stored
    on custom stores like Session or database
    -ViewState contains the values that aren't carried along with the request
    normally, yes, helping with control persistence over postbacks (only the
    values, not controls themselves)
    -Yes, ViewState is kept even if control wouldn't be rendered (occasionally
    hidden control can keep its state as long as it is along with the controls
    collection between the subsequent requests by the same client)
    -As far as I know, persisting the state (like with DataGrid) is all or
    nothing. This is though a place for custom paging solution when you don't
    need to bind that much records, but data store handles the paging not the
    grid from all the data. E.g one page at a time is bound to the grid and
    stored to ViewState (ViewState isn't for the paging in this case actually
    but to keep the grid if some other controls causes a postback and grid isn't
    databound on all request, as it shouldn't be)
    -Yes, thanks to ViewState you need only to rebind the controls when logic
    requires to.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist






    "Sky" <-solutions.com> wrote in message
    news:...
    Although I've been using C# for the last month or so, and accepting out of
    blind faith the ViewState, I do have some nagging questions about it... can
    you help verify the following statements?

    Application is across all sessions.
    Session is across all pages.
    ViewState is sort of like Session, but for only one page. <-- Correct
    statement?

    Session is stored between page requests, somewhere in mem or IIS files --
    but can be rerouted to DB.
    ViewState is sent to Client and returned on every post <-- Correct
    statement?

    If you load a DataSet.Table of 10 columns, 10 rows, and Bind it to a
    DataGrid
    you are sending to the Client 10x10 html cells of a table -- PLUS in the
    ViewState 10x10 values encrypted. <--Correct statement?

    If you load a DataSet.Table of 10 columns, 10 rows, and Bind it to a
    DataGrid
    but hide 7 columns you are sending to the Client 3x10 html cells of a
    table -- PLUS in the ViewState 10x10 values encrypted. <--Correct statement?

    Therefore, if you load a DataTable with 10 columns, 1000 rows, Bind it to a
    DataGrid, but put Paging on 10 per page...
    I am sending 10x10 html cells to the client -- PLUS 10x1000 cells in the
    ViewState?????


    If I DataBind a DataTable to a grid on page_load, I don't have to rebind it
    again until I update the database, and have to repick up the new DataSet <-
    Correct?


    Any other comments you may have as to what it is, and "how to think of it"?

    Thank you so much,
    Sky
    Teemu Keiski, Jan 31, 2004
    #2
    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. Bigal

    Viewstate versus performance

    Bigal, Aug 1, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    341
    Gary McCormack
    Aug 1, 2003
  2. Matthew Louden
    Replies:
    1
    Views:
    6,894
    Scott M.
    Oct 11, 2003
  3. Russ

    script versus code versus ?

    Russ, Jun 10, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,483
  4. Christoffer Sawicki
    Replies:
    5
    Views:
    241
    Christoffer Sawicki
    Sep 2, 2006
  5. Paul Butcher
    Replies:
    12
    Views:
    693
    Gary Wright
    Nov 28, 2007
Loading...

Share This Page