We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Exception with GridGroupingcontrol

I'm using a GridGroupingControl in ASP.NET and setting it's data source to a DataView object (although, setting it to a DataTable gives the same error). The underlying table doesn't have any Expression columns but I keep getting the error described by the stack trace (see below).

It turns out we have some DataColumns that have Expression properties set where the Expression string references the name of the column that it uses. Apparently, this causes a headache when you try and clone it (what the GGC.SaveViewState does).
OK, so I made a fix for that, but now when the Clone method for a table gets called, it throws a different exception: 'Unable to find column [columnName]'. I think this is because the table that has [columnName] itself, hasn't been cloned yet.
But my real question is: Why do all the tables in the dataset that the table (that the grid binds to) need to be saved in the view state by the grid?

[ArgumentException: Cannot set Expression property due to circular reference in the expression.]
System.Data.DataColumn.set_Expression(String value) +745
System.Data.DataTable.CloneTo(DataTable clone, DataSet cloneDS, Boolean skipExpressionColumns) +1871979
System.Data.DataTable.Clone(DataSet cloneDS) +90
System.Data.DataTable.Clone() +6
Syncfusion.Web.UI.WebControls.Grid.Grouping.Common.Utils.ConvertDataViewToDataTable(DataView dv) +83
Syncfusion.Web.UI.WebControls.Grid.Grouping.GridGroupingControl.SaveSourceListSet() +1049
Syncfusion.Web.UI.WebControls.Grid.Grouping.GridGroupingControl.SaveViewState() +135
System.Web.UI.Control.SaveViewStateRecursive() +59


4 Replies

RP Rekha P Syncfusion Team March 13, 2009 01:26 PM UTC

Hi Mark,

Thank you for your interest in Syncfusion Products.

Why do all the tables in the dataset that the table (that the grid binds to) need to be saved in the view state by the grid?

Grid Grouping Control provides built-in support for data caching. The need for querying the datasource for every postback and callback roundtrip is eliminated, thus enhancing grid performance and minimizing load time. In order to persist the changes to the state of a GridGroupingControl across postbacks, the ViewState is maintained and the datasource object will be serialized and added to view state.

Regarding the exception with GridGroupingcontrol issue, please refer the online sample below which illustrates expression fields in columns.

http://samples.syncfusion.com/ASPNET/7.1.0.30/Web/grid.grouping.web/samples/3.5/ColumnOrRows/UnboundColumns/CS/ExpressionFields.aspx

Please have a look at the above sample and if still the issue exists, could you please try reproducing it in a simple sample and send us the sample so that we could sort out the cause of the issue and provide you a solution?

Please let me know if you have any other concerns.

Thanks,
Rekha



AD Administrator Syncfusion Team March 13, 2009 04:32 PM UTC


I understand why the datasource object should be serialized in the view state, but what I don't understand is why does the entire dataset that the binding datasource (say, a DataTable or DataView) is connected to need to be persisted. Tables that have nothing to do with the grid are being persisted in the viewstate by the grid.

>Grid Grouping Control provides built-in support for data caching. The need for querying the datasource for every postback and callback roundtrip is eliminated...In order to persist the changes to the state of a GridGroupingControl across postbacks, the ViewState is maintained and the datasource object will be serialized and added to view state.





AD Administrator Syncfusion Team March 13, 2009 07:51 PM UTC

Here's another similar exception.
The GridGroupingControl isn't bound to either of the tables that make up the DataRelation 'FK_GNCommon_LCLicensee'. For some reason, the SaveViewState method of GridGroupingControl is cloning every table in the dataset that the bound DataView belongs to.

[EvaluateException: Cannot find the parent relation 'FK_GNCommon_LCLicensee'.]
System.Data.LookupNode.Bind(DataTable table, List`1 list) +1291820
System.Data.DataExpression.Bind(DataTable table) +60
System.Data.DataExpression..ctor(DataTable table, String expression, Type type) +1314331
System.Data.DataColumn.set_Expression(String value) +101
System.Data.DataTable.CloneTo(DataTable clone, DataSet cloneDS, Boolean skipExpressionColumns) +1871979
System.Data.DataTable.Clone(DataSet cloneDS) +90
System.Data.DataTable.Clone() +6
Syncfusion.Web.UI.WebControls.Grid.Grouping.Common.Utils.ConvertDataViewToDataTable(DataView dv) +83
Syncfusion.Web.UI.WebControls.Grid.Grouping.GridGroupingControl.SaveSourceListSet() +1051
Syncfusion.Web.UI.WebControls.Grid.Grouping.GridGroupingControl.SaveViewState() +135
CityView.WebCommon.UI.WebGrid.SaveViewState() in C:\backup\Trunk\CityView\Web\WebCommon\UI\WebGrid.cs:70
System.Web.UI.Control.SaveViewStateRecursive() +59





RP Rekha P Syncfusion Team March 16, 2009 09:35 AM UTC

Hi Mark,

Tables that have nothing to do with the grid are being persisted in the viewstate by the grid.

When DataSourceCachingMode is set to ViewState in GridGroupingControl, then the datasource object will be serialized and added to view state. That is, datasource referenced will persist in the viewstate, this is the default behavior of the control. For instance, if a DataTable has 10 columns and only 5 columns are referred by Grid, then all the 10 columns will be maintained in viewstate. If your intension is to not to use data caching, then DataSourceCachingMode can be specified to none.

this.GridGroupingControl1.DataSourceCachingMode = DataSourceCachingMode.None;

This mode will turns off data caching and the datasource must be initialized for every postback and callback.

Please let me know if you have any other concerns.

Thanks,
Rekha


Loader.
Live Chat Icon For mobile
Up arrow icon