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.
Unfortunately, activation email could not send to your email. Please try again.

GDBD Refresh problem with same DataTable but data changed

Thread ID:





26714 Mar 30,2005 12:42 PM Mar 30,2005 05:02 PM Windows Forms 6
Tags: GridControl
Asked On March 30, 2005 12:42 PM

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 12:46 PM

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 01:19 PM

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

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

>>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 03:22 PM

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 04:43 PM

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 05:02 PM

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.

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.