This is a migrated thread and some comments may be shown as answers.

Skip loading view state?

2 Answers 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eve Cunning
Top achievements
Rank 1
Eve Cunning asked on 25 Nov 2009, 07:11 PM
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 Answers, 1 is accepted

Sort by
0
Roland
Top achievements
Rank 1
answered on 26 Nov 2009, 01:30 AM
You can completely disable view state for  your grid.
Please refer to this documentation regarding Grid Event Sequence with disabled viewstate.
0
Eve Cunning
Top achievements
Rank 1
answered on 01 Dec 2009, 02:44 PM
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
Tags
Grid
Asked by
Eve Cunning
Top achievements
Rank 1
Answers by
Roland
Top achievements
Rank 1
Eve Cunning
Top achievements
Rank 1
Share this question
or