The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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
ADAdministrator 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
BRBrandon RichterApril 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.
PEPua Eng HengApril 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
BRBrandon RichterApril 28, 2005 02:27 PM UTC
BRBrandon RichterMay 12, 2005 08:23 PM UTC
ADAdministrator Syncfusion Team May 13, 2005 12:16 PM UTC
Before you reset the datasource, clear the grid.GridBoundColumns collection if they have been used.