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

DynamicQuery ViewState

1 Answer 26 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nicholas Walker
Top achievements
Rank 1
Nicholas Walker asked on 26 Sep 2008, 05:37 PM
I am using a linq to entities data source where the columns are determined run time, and uses a library called DynamicQuery.  This library creates a dynamic assembly.

Even with EnableViewState="false" the datasource definition seems to be stored in viewstate, and is attempting to be deserialized.  When it tries to deserialize an error is thrown that the assembly that was previously used is no longer available.

Is there any way to prevent the datasource object from being saved into viewstate?

Note: When I completely turn ViewState off at the control level, the page works, but the Paging and event processing is broken with the grid when this is done.

1 Answer, 1 is accepted

Sort by
0
Nicholas Walker
Top achievements
Rank 1
answered on 26 Sep 2008, 08:21 PM
I found a work around for this by converting by data source to a datatable before it gets databinded.  The ViewState is storing the definition of the object within the datatable, so if I have a list of pigs, it is storing at least one object of type pig in viewstate even with viewstate turned off

It doesn't seem like it's necessary to do that, but I have found a work around for my issue.
Tags
Grid
Asked by
Nicholas Walker
Top achievements
Rank 1
Answers by
Nicholas Walker
Top achievements
Rank 1
Share this question
or