Help is needed.

  • Thread starter Thread starter Alan
  • Start date Start date
A

Alan

I will need to load data from a datatable to a datagrid several times. How
do I clear the contents of the datagrid before loading the contents into the
datagrid ?
 
As you set the DataGrid's datasource, you'll need to call the DataGrid's
DataBind method. This will essentially reset the grid to the new data.
 
Sorry, can you give me the code of that please ?

Scott M. said:
As you set the DataGrid's datasource, you'll need to call the DataGrid's
DataBind method. This will essentially reset the grid to the new data.
 
In order to bind the DataGrid to some data, you must set its DataSource
property...

DataGrid.DataSource = "someDataSource" 'Could be a DataSet, XML, a
DataTable, etc.

Then to actually put the data in the grid, you have to call its DataBind
method....

DataGrid.DataBind()

This populates the grid. If you need to put different data into the grid
than you had earlier, you can set the grid to its new data source and call
databind.
 
Back
Top