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

GDBG not resetting after schema change

Hi, There have been several posts on this topic before and I''ve tried all the suggestions, but it just isn''t happening. I have a GDBG bound to a table in a dataset. The schema of the table changes after a few buttons are pressed and I''m trying to get the grid to drop everything it has and reinitialize itself. Below are the statements I''ve tried calling to do this, but when loading a second time, it keeps the columns that were present in the first load. data.Reset() ''data is a dataset data = db.UnthreadedQuery(sql_string) ''returns data in the ''results'' datatable data.Tables("results").Columns.Add("S", GetType(String)) ''start GRID UPDATE Me.Cursor = Cursors.WaitCursor datagrid1.BeginUpdate() datagrid1.DataSource = Nothing datagrid1.DataMember = Nothing ''datagrid1.ResetProperties() datagrid1.Model.ResetVolatileData() ''datagrid1.Initialize() ''datagrid1.Model.Refresh() datagrid1.DataSource = data.Tables("results").DefaultView() datagrid1.Model.Cols.MoveRange(datagrid1.Binder.NameToColIndex("S"), 1) datagrid1.Model.ColWidths.SetSize(datagrid1.Binder.NameToColIndex("S"), 20) datagrid1.Model.ColWidths.ResizeToFit(GridRangeInfo.Cols(2, datagrid1.Model.ColCount)) datagrid1.BaseStylesMap("Row Header").StyleInfo.CellType = "Header" ''show numbers in the row headers datagrid1.Binder.AutoInitCellTypes = False datagrid1.Binder.EnableEdit = False datagrid1.Binder.InitializeColumns() datagrid1.TableStyle.Trimming = StringTrimming.EllipsisCharacter datagrid1.Model.ColWidths.ResizeToFit(GridRangeInfo.Row(0), GridResizeToFitOptions.NoShrinkSize) datagrid1.ListBoxSelectionMode = SelectionMode.MultiExtended datagrid1.AllowDragSelectedCols = True datagrid1.EndUpdate() datagrid1.Refresh() Me.Cursor = Cursors.Arrow Thanks for your help, Brandon

6 Replies

AD Administrator Syncfusion Team April 25, 2005 02:57 PM UTC

Calling data.Reset actually removes all tables from the DataSet. Does db.UnthreadQuery add them back? Here is a sample that uses dataset.Reset to display new datasources in a grid. But it does have to re-add the Datatable(s) after the Reset. http://www.syncfusion.com/Support/user/uploads/GDBG_ResetDatasource_504298cb.zip


BR Brandon Richter April 25, 2005 05:52 PM UTC

Yes, the unthreaded query function adds the "results" datatable to the dataset if it does not already exist. I have verified this by outputting data.tables("results").columns.count to a textbox after the grid refresh/update event is raised.


PE Pua Eng Heng April 26, 2005 07:44 AM UTC

Hi Clay, I have encountered similar problem (which I post in another thread). Using your sample, I could reproduce similar problem. This is whay I did. Click the ResetGrid button until the grid show 2 columns. Now change the column sequnce by dragging the column header. Then click the ResetGrid button many time, you will find that the data changes but number of column shown in the grid always remain 2 columns. I think the grid also needs some kind of reset ??? Regards Pua Eng Heng >Hi, > >There have been several posts on this topic before and I''ve tried all the suggestions, but it just isn''t happening. I have a GDBG bound to a table in a dataset. The schema of the table changes after a few buttons are pressed and I''m trying to get the grid to drop everything it has and reinitialize itself. Below are the statements I''ve tried calling to do this, but when loading a second time, it keeps the columns that were present in the first load. > > >data.Reset() ''data is a dataset > >data = db.UnthreadedQuery(sql_string) ''returns data in the ''results'' datatable >data.Tables("results").Columns.Add("S", GetType(String)) > >''start GRID UPDATE >Me.Cursor = Cursors.WaitCursor >datagrid1.BeginUpdate() > >datagrid1.DataSource = Nothing >datagrid1.DataMember = Nothing > >''datagrid1.ResetProperties() >datagrid1.Model.ResetVolatileData() >''datagrid1.Initialize() >''datagrid1.Model.Refresh() > >datagrid1.DataSource = data.Tables("results").DefaultView() > >datagrid1.Model.Cols.MoveRange(datagrid1.Binder.NameToColIndex("S"), 1) >datagrid1.Model.ColWidths.SetSize(datagrid1.Binder.NameToColIndex("S"), 20) >datagrid1.Model.ColWidths.ResizeToFit(GridRangeInfo.Cols(2, datagrid1.Model.ColCount)) > >datagrid1.BaseStylesMap("Row Header").StyleInfo.CellType = "Header" ''show numbers in the row headers >datagrid1.Binder.AutoInitCellTypes = False >datagrid1.Binder.EnableEdit = False >datagrid1.Binder.InitializeColumns() > > > >datagrid1.TableStyle.Trimming = StringTrimming.EllipsisCharacter >datagrid1.Model.ColWidths.ResizeToFit(GridRangeInfo.Row(0), GridResizeToFitOptions.NoShrinkSize) > >datagrid1.ListBoxSelectionMode = SelectionMode.MultiExtended >datagrid1.AllowDragSelectedCols = True > >datagrid1.EndUpdate() >datagrid1.Refresh() >Me.Cursor = Cursors.Arrow > > >Thanks for your help, >Brandon


BR Brandon Richter April 28, 2005 02:27 PM UTC



BR Brandon Richter May 12, 2005 08:23 PM UTC



AD Administrator Syncfusion Team May 13, 2005 12:16 PM UTC

Before you reset the datasource, clear the grid.GridBoundColumns collection if they have been used.
this.ds.Tables.Add(dt);
if(this.gridDataBoundGrid1.GridBoundColumns.Count > 0)  //added
	this.gridDataBoundGrid1.GridBoundColumns.Clear();   //added
this.gridDataBoundGrid1.DataSource = ds.Tables["MyTable"];

Loader.
Live Chat Icon For mobile
Up arrow icon