Friday, May 14, 2010

How to convert the output of a SQLDataSource.Select to a DataTable

/*Step 1 : First convert source of a SQLDataSource into a DataView */
DataView dv = (DataView)SqlDataSourceStudentsOnly.Select(DataSourceSelectArguments.Empty);
/*Step 2: Cast it to DataTable using ToTable() method of DataSet */

DataTable dt = (DataTable)dv.ToTable();

No comments: