|
How to convert the data source in the GridView to a DataTable.
There are two ways to get the data source of GridView, one is through the DataSource,
One is obtained through DataSourceID, such as
Way 1
this.GridView1.DataSource = this.ObjectDataSource1;
this.GridView1.DataBind ();
Way 2
this.GridView1.DataSourceID = "ObjectDataSource1";
this.GridView1.DataBind ();
Note: There may be many types of data sources in the GridView, which may be DataSet, DataTable,
DataView, DataReader, SqlDataSource, ObjectDataSource.
If the data source is a DataTable or something, that's easy to use.
this.GridView1.DataSource as DataTable is ok.,
But if it is a data source control such as ObjectDataSource, this will not work. Does anyone know how to complete the above requirements? |
|