Skip loading view state?

3 posts, 0 answers
  1. Eve Cunning
    Eve Cunning avatar
    14 posts
    Member since:
    Oct 2009

    Posted 25 Nov 2009 Link to this post

    I have a RadGrid in which the contents and column settings are dictated by a dropdownlist.

    When a dropdownlist item is selected, the grid's data and various configurable grid settings (like reordering, sorting, filtering, and column widths) are loaded from the database.  The user can then manipulate various settings client-side and optionally save them out again.

    • When an Ajax postback occurs, like refreshing the grid, the settings are maintained by the viewstate as usual.  For instance, if the user has changed the column width, that is maintained, no problem.

    • However, when the dropdownlist selection changes, causing a totally new set of data and settings to be loaded, any viewstate settings for the old data must be abandoned.  The solution we tried was overriding LoadViewState to do nothing in this case, but we get a NullReferenceException from RadGrid.LoadClientState if a column is resized and then the dropdownlist selection is changed.  If no columns have been resized, it works.  Also, column-resizing seems to be the only setting for which the exception happens (that I've found so far).

    Do you have any suggestions here, either a better way to clear the grid's viewstate on a new data load, or perhaps a workaround for the resizing issue?

    Thanks very much,
    Eve



  2. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 25 Nov 2009 Link to this post

    You can completely disable view state for  your grid.
    Please refer to this documentation regarding Grid Event Sequence with disabled viewstate.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Eve Cunning
    Eve Cunning avatar
    14 posts
    Member since:
    Oct 2009

    Posted 01 Dec 2009 Link to this post

    We did not want to disable viewstate, just ignore its contents under various circumstances.

    The solution turned out to be overloading LoadViewState and LoadClientViewState in a RadGrid subclass, and not call the base class versions at those times we don't want the current viewstate applied.

    Thanks,
    Eve
Back to Top