Trying to build in an admin tool in VB.Net that will display display data based upon a dynamic sql selection from any table. Works fine the first time through, the second time the columns on the DevExpress XtraGrid displayed match the new SQL statement and result set, the data table has data, the grid properties should the data source correctly with data but the data does not show up on the grid during display.
Try
'Initialize Datatable and Grid
dt.Reset()
GridView1.Columns.Clear()
grdAdminSQL.DataSource = Nothing
'Get the data and load into data table
myCmd = myConn.CreateCommand
myCmd.CommandText = tbAdmSQL.Text.Trim
myConn.Open()
myreader = myCmd.ExecuteReader()
dt.Load(myreader)
'Reset the Data Source on the grid
grdAdminSQL.DataSource = dt
grdAdminSQL.RefreshDataSource()
Catch ex As Exception
Finally
myConn.Close()
myConn.Dispose()
End Try
I think that is because
GridView1.Columns.Clear()isn't enough to let DevExpress know it needs to re-create the columns.You need to also call
after you have set your dataSource.
If that doesn't work, add