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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GDBD Refresh problem with same DataTable but data changed

Thread ID:





26714 Mar 30,2005 05:42 PM UTC Mar 30,2005 10:02 PM UTC WinForms 6
Tags: GridControl
Asked On March 30, 2005 05:42 PM UTC

I defined a GridDataBoundGrid and a DataTable in my code. I have a methos called ShowTable which has following lines: this.grid.DataMember = ""; this.grid.DataSource = dataTable; The first time there''s no problem of display. But when the data in my dataTable changed, I need to refresh the grid so ShowTable will be called again. Somehow the grid didn''t bind to the dataTable. So the display just show the header of the table, no data. How to solve this? Thanks, Mechelle

Administrator [Syncfusion]
Replied On March 30, 2005 05:46 PM UTC

Try this to see if if avoids this problem. this.grid.DataMember = ""; this.grid.DataSource = null; this.grid.DataSource = dataTable; //maybe add one or both of of these lines this.grid.Binder.InitializeColumns(); this.grid.Refresh();

Replied On March 30, 2005 06:19 PM UTC

Thanks for the reply. I tried the recommeded code, but it doesn''t work either. Mechelle

Administrator [Syncfusion]
Replied On March 30, 2005 06:56 PM UTC

>>when the data in my dataTable changed What do you mean by this? Do you mean the datatable is destroyed and reloaded as a new DataTable with different columns? Or, do you mean that just some other process has modifed values in the DataTable? If you are destoying the DataTable while it is still set as the grid''s datasource, then this would be a problem. You should first set grid.DataSource = null; then destroy the DataTable and recreate it, and then reset it as teh grid''s DataSource. If you will explain more about what you are doing, then maybe we can suggest some solution.

Replied On March 30, 2005 08:22 PM UTC

In the method of ShowTable(), my datatable is defined as following: dataTable.Reset(); dataTable.AcceptChanges(); dataTable.Columns.Add("Computers", typeof(String)); dataTable.Columns.Add("Result",typeof(String)); BuildTableContents(); //Updates latest data from a SortedList to this dataTable grid.DataMember = ""; grid.DataSource = null; grid.DataSource = dataTable; When I say dataTable changes, I mean the data(contents) changed. The schema doesn''t. And I can verify that the data in the dataTable has been updated through the debugger. But "grid.DataSource = dataTable;" doesn''t bind the grid to the table data for the 2nd time. Although the first time it binds no problem. Somehow the 2nd time the column name is showed up, but no data. Mechelle

Administrator [Syncfusion]
Replied On March 30, 2005 09:43 PM UTC

If the schema does not change, try calling DataTable.Clear instead of DataTable.Reset. The reset causes a similar problem if you try doing something like this with a Windows Forms DataGrid. Here is a little sample that has a button that loads a Datatable many times with different data using DataTable.Clear. http://www.syncfusion.com/Support/user/uploads/GDBG_ResetDatasource_75ea892e.zip

Replied On March 30, 2005 10:02 PM UTC

Thank you for the suggestion. Using DataTable.Clear() fix the problem. Thank you again. Mechelle


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon