disabling viewstate on datagrid

Discussion in 'ASP .Net' started by sonic, Feb 16, 2005.

  1. sonic

    sonic Guest

    Hi,
    I am experimenting with different viewstate management ideas for large
    datagrids, and found a microsoft suggestion to turn it off, and only
    store relevant information by manually accessing viewstate. as per some
    helpful suggestins in MSDN "Common DataGrid Mistakes"
    http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp

    they suggest disabling datagrid viewstate and adding selective
    information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.

    the problem i encountered is, when i set EnableViewState=false, nothing
    gets saved there, even though i explicitly save / load viewstate
    variables.

    Any advice in having it disabled but still using it ?
     
    sonic, Feb 16, 2005
    #1
    1. Advertising

  2. Where do you specify EnableViewState=false? For the whole page in the <%@
    Page...> directive? You should do it only for the grid and other components
    you want the ViewState to be off.

    Eliyahu

    "sonic" <> wrote in message
    news:...
    > Hi,
    > I am experimenting with different viewstate management ideas for large
    > datagrids, and found a microsoft suggestion to turn it off, and only
    > store relevant information by manually accessing viewstate. as per some
    > helpful suggestins in MSDN "Common DataGrid Mistakes"
    >

    http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp
    >
    > they suggest disabling datagrid viewstate and adding selective
    > information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.
    >
    > the problem i encountered is, when i set EnableViewState=false, nothing
    > gets saved there, even though i explicitly save / load viewstate
    > variables.
    >
    > Any advice in having it disabled but still using it ?
    >
     
    Eliyahu Goldin, Feb 16, 2005
    #2
    1. Advertising

  3. sonic

    sonic Guest

    disabling it in datagrid as mentioned above
     
    sonic, Feb 16, 2005
    #3
  4. I have the same problem. When I disable datagrid viewstate, it skips the
    datagrid1__SelectedIndexChanged routine entirely.

    George

    "Eliyahu Goldin" wrote:

    > Where do you specify EnableViewState=false? For the whole page in the <%@
    > Page...> directive? You should do it only for the grid and other components
    > you want the ViewState to be off.
    >
    > Eliyahu
    >
    > "sonic" <> wrote in message
    > news:...
    > > Hi,
    > > I am experimenting with different viewstate management ideas for large
    > > datagrids, and found a microsoft suggestion to turn it off, and only
    > > store relevant information by manually accessing viewstate. as per some
    > > helpful suggestins in MSDN "Common DataGrid Mistakes"
    > >

    > http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp
    > >
    > > they suggest disabling datagrid viewstate and adding selective
    > > information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.
    > >
    > > the problem i encountered is, when i set EnableViewState=false, nothing
    > > gets saved there, even though i explicitly save / load viewstate
    > > variables.
    > >
    > > Any advice in having it disabled but still using it ?
    > >

    >
    >
    >
     
    =?Utf-8?B?R2Vvcmdl?=, May 10, 2005
    #4
  5. sonic

    vMike Guest

    "George" <> wrote in message
    news:...
    >I have the same problem. When I disable datagrid viewstate, it skips the
    > datagrid1__SelectedIndexChanged routine entirely.
    >
    > George
    >
    > "Eliyahu Goldin" wrote:
    >
    >> Where do you specify EnableViewState=false? For the whole page in the <%@
    >> Page...> directive? You should do it only for the grid and other
    >> components
    >> you want the ViewState to be off.
    >>
    >> Eliyahu
    >>
    >> "sonic" <> wrote in message
    >> news:...
    >> > Hi,
    >> > I am experimenting with different viewstate management ideas for large
    >> > datagrids, and found a microsoft suggestion to turn it off, and only
    >> > store relevant information by manually accessing viewstate. as per some
    >> > helpful suggestins in MSDN "Common DataGrid Mistakes"
    >> >

    >> http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp
    >> >
    >> > they suggest disabling datagrid viewstate and adding selective
    >> > information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.
    >> >
    >> > the problem i encountered is, when i set EnableViewState=false, nothing
    >> > gets saved there, even though i explicitly save / load viewstate
    >> > variables.
    >> >
    >> > Any advice in having it disabled but still using it ?
    >> >

    >>
    >>
    >>

    Try reloading the datagrid on page_init or page_load even during postback.
    Mike
     
    vMike, May 10, 2005
    #5
  6. Thanks vMike. Probably that's the only way to databind the datagrid
    everytime. But how do I know what is the new page selection, or the sort
    column, if I databind in the Page_Load?

    George

    "vMike" wrote:

    >
    > "George" <> wrote in message
    > news:...
    > >I have the same problem. When I disable datagrid viewstate, it skips the
    > > datagrid1__SelectedIndexChanged routine entirely.
    > >
    > > George
    > >
    > > "Eliyahu Goldin" wrote:
    > >
    > >> Where do you specify EnableViewState=false? For the whole page in the <%@
    > >> Page...> directive? You should do it only for the grid and other
    > >> components
    > >> you want the ViewState to be off.
    > >>
    > >> Eliyahu
    > >>
    > >> "sonic" <> wrote in message
    > >> news:...
    > >> > Hi,
    > >> > I am experimenting with different viewstate management ideas for large
    > >> > datagrids, and found a microsoft suggestion to turn it off, and only
    > >> > store relevant information by manually accessing viewstate. as per some
    > >> > helpful suggestins in MSDN "Common DataGrid Mistakes"
    > >> >
    > >> http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp
    > >> >
    > >> > they suggest disabling datagrid viewstate and adding selective
    > >> > information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.
    > >> >
    > >> > the problem i encountered is, when i set EnableViewState=false, nothing
    > >> > gets saved there, even though i explicitly save / load viewstate
    > >> > variables.
    > >> >
    > >> > Any advice in having it disabled but still using it ?
    > >> >
    > >>
    > >>
    > >>

    > Try reloading the datagrid on page_init or page_load even during postback.
    > Mike
    >
    >
    >
     
    =?Utf-8?B?R2Vvcmdl?=, May 12, 2005
    #6
  7. sonic

    vMike Guest

    "George" <> wrote in message
    news:...
    > Thanks vMike. Probably that's the only way to databind the datagrid
    > everytime. But how do I know what is the new page selection, or the sort
    > column, if I databind in the Page_Load?
    >
    > George
    >
    > "vMike" wrote:
    >
    > >
    > > "George" <> wrote in message
    > > news:...
    > > >I have the same problem. When I disable datagrid viewstate, it skips

    the
    > > > datagrid1__SelectedIndexChanged routine entirely.
    > > >
    > > > George
    > > >
    > > > "Eliyahu Goldin" wrote:
    > > >
    > > >> Where do you specify EnableViewState=false? For the whole page in the

    <%@
    > > >> Page...> directive? You should do it only for the grid and other
    > > >> components
    > > >> you want the ViewState to be off.
    > > >>
    > > >> Eliyahu
    > > >>
    > > >> "sonic" <> wrote in message
    > > >> news:...
    > > >> > Hi,
    > > >> > I am experimenting with different viewstate management ideas for

    large
    > > >> > datagrids, and found a microsoft suggestion to turn it off, and

    only
    > > >> > store relevant information by manually accessing viewstate. as per

    some
    > > >> > helpful suggestins in MSDN "Common DataGrid Mistakes"
    > > >> >
    > > >>

    http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp
    > > >> >
    > > >> > they suggest disabling datagrid viewstate and adding selective
    > > >> > information to it i.e. ViewState["editindex"] = this.EditItemIndex

    etc.
    > > >> >
    > > >> > the problem i encountered is, when i set EnableViewState=false,

    nothing
    > > >> > gets saved there, even though i explicitly save / load viewstate
    > > >> > variables.
    > > >> >
    > > >> > Any advice in having it disabled but still using it ?
    > > >> >
    > > >>
    > > >>
    > > >>

    > > Try reloading the datagrid on page_init or page_load even during

    postback.
    > > Mike
    > >
    > >
    > >

    In general, if the datagrid is user specific you may need to maintain
    viewstate or it will go back to its original state. The only other choice is
    to maintain some hidden fields or other smaller items in viewstate that will
    enable you to recreate the datagrid in the state that the user had at the
    time of postback. IMHO viewstate is used to maintain the state of controls
    that are specific to one user as opposed to any user.
     
    vMike, May 12, 2005
    #7
    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. Mark Rodseth

    Disabling ViewState on a Repeater Control

    Mark Rodseth, Dec 9, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    480
    Mark Rodseth
    Dec 9, 2003
  2. Jim Cheshire [MSFT]

    RE: Disabling Viewstate

    Jim Cheshire [MSFT], Feb 27, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,630
    Jim Cheshire [MSFT]
    Feb 27, 2004
  3. Replies:
    3
    Views:
    4,600
    Juan T. Llibre
    Nov 29, 2005
  4. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    Disabling ViewState Throughout

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Dec 31, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    282
    Joe (MCAD)
    Jan 1, 2007
  5. JJ
    Replies:
    1
    Views:
    375
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Feb 22, 2007
Loading...

Share This Page