Not sure why ViewState isn't working...

Last post 07-02-2009 8:40 AM by integrasol. 1 replies.

Sort Posts:

  • Not sure why ViewState isn't working...

    07-02-2009, 6:53 AM

    My custom server control generates a table, containing custom cells containing textboxes that have been populated with data from the database.

    All the textboxes are editable, and there is a Button control that causes a postback.

    By default, if I click this button, obviously any changes I made to the textboxes will be overwritten as the first thing the control does is get the data from the dataset and populate the textboxes. So I save the values in viewstate myself by creating a viewstate property. (I just write this code once as I have a nested custom control for each table cell.)

    Unfortunately, the values don't seem to be saving to viewstate, as when the controls try to load viewstate, it is empty.

    What am I doing wrong? Is this a problem with using custom server controls? Is it because it is regenerating the cells each time and treating them as brand new?

    Disco Patrick writes web applications using:

    Visual Studio 2008
    ASP.NET 3.5
    C#
    SQL Server 2008
  • Re: Not sure why ViewState isn't working...

    07-02-2009, 8:40 AM
    Answer
    • Contributor
      7,264 point Contributor
    • integrasol
    • Member since 06-05-2009, 11:18 AM
    • Posts 1,382

    You might want to check out control state instead of View state, http://msdn.microsoft.com/en-us/library/1whwt1k7.aspx

    Thanks

    Carsten

    Please mark this post as Answer if it is of help to you. :-)
Page 1 of 1 (2 items)