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
close icon

Refresh grid content after changing datasource

I'm changing the datasource for a gridgroupingcontrol in the following way:

m_BindingSource.DataSource = newDataSource;
m_GridControl.DataSource = m_BindingSource;

newDataSource contains a data table with a different column setup compared to the previous data table bound to the grid.

My problem is that I can't make the grid reload the values with the new data source correctly. The columns all show up OK but the content (cell values) is not correct.

I'm using stacked row headers and expression fields in the grid, and before rebuilding these (after changing the datasource) I do the following:
gridTableDescriptor.Columns.Reset(); gridTableDescriptor.ResetExpressionFields();
gridTableDescriptor.ResetStackedHeaderRows();

GridGroupingControl 5.102.0.51
VS.NET 2005

What is the correct way of reloading data in the GGC after changing datasource to a new data table with a different column setup?

Any suggestions greatly appreciated.

Regards
/Marten

4 Replies

HA haneefm Syncfusion Team June 6, 2007 06:04 PM UTC

Hi Marten,

You can try this code snippets to reset the datasource for the grid and see if it helps.

[c#]
this.gridGroupingControl1.DataSource = null;
this.gridGroupingControl1.DataMember = null;
this.gridGroupingControl1.ResetTableDescriptor();
this.gridGroupingControl1.TableDescriptor.Relations.Clear();
this.gridGroupingControl1.DataSource = newdatasource;
this.gridGroupingControl1.Refresh();


Please refer the GridGroupingRebind sample in the browser samples shipped with the product.
[instal path]\Syncfusion\Essential Studio\4.4.0.51\windows\Grid.Grouping.Windows\Samples\FeatureSamples\GridGroupingRebind

This sample demonstrates the switching of datasources at runtime and how to reset the GridGroupingControl to its original empty state.

Best regards,
Haneef


ML Mårten Lind June 6, 2007 08:03 PM UTC

Thanks Haneef,

Now it's working as expected.

Couldn't find the GridGroupingRebind sample for my GGC version (5.102.0.51). Any idea where I can find the sample you're refering too?

Cheers
/Marten


HA haneefm Syncfusion Team June 6, 2007 08:57 PM UTC

Hi Marten,

Please find the attached sample below and let me know if this helps.
GridGroupingRebind.zip

Best regards,
Haneef


ML Mårten Lind June 7, 2007 09:09 AM UTC

Hi again,

Thanks for the sample. My problem was solved when calling gridGroupingControl1.ResetTableDescriptor();

Thanks for a quick answer,

Cheers
/Marten

Loader.
Live Chat Icon For mobile
Up arrow icon