A
Alexander
Hi, I am using a DataGrid and assign a DataTable as a DataSource to
it:
void ShowData()
{
DataTable myNewDataTable = new DataTable();
... // fill table
this.m_DataGrid1.DataSource = myNewDataTable;
this.Refresh();
}
I create the DataTable from the scratch of some XML data and then
simply assign it. This works perfectly, the table with all the columns
is displayed.
If I call the function a second time, and assign a new DataTable as a
DataSource, the new table is added to the grid instead of replacing
the old one. So if the old table had columns 1, 2 and 3 and the new
table 98, 99, the result is a grid with the columns 1, 2, 3, 98, 99.
I already debugged, to make sure if the new DataTable really has only
2 columns and that afterwards the new DataSource of the DataGrid has
only 2 columns, too. But displayed are 5 columns afterwards...
Is there a special trick to replace the DataSource?
it:
void ShowData()
{
DataTable myNewDataTable = new DataTable();
... // fill table
this.m_DataGrid1.DataSource = myNewDataTable;
this.Refresh();
}
I create the DataTable from the scratch of some XML data and then
simply assign it. This works perfectly, the table with all the columns
is displayed.
If I call the function a second time, and assign a new DataTable as a
DataSource, the new table is added to the grid instead of replacing
the old one. So if the old table had columns 1, 2 and 3 and the new
table 98, 99, the result is a grid with the columns 1, 2, 3, 98, 99.
I already debugged, to make sure if the new DataTable really has only
2 columns and that afterwards the new DataSource of the DataGrid has
only 2 columns, too. But displayed are 5 columns afterwards...
Is there a special trick to replace the DataSource?