Hi Paul,
If I would use DataTable instead of the DataSet, how can I update my GridView SQLDataSource when I have my new datatable. Should I somehow remove the existing DataTable and add this new one?
Do you have some code for this?
Thanks again.
>>Hi everybody,
>>
>>I found this link
http://msmvps.com/blogs/egoldin/archive/2006/12/27/how-to-get-datatable-out-of-sqldatasource.aspx>>
>>So, I can get the DataTable.
>>
>>I need to create a dataset with this data and save it to the session.
>>
>>Do you know how can I do this?
>>
>>Can I somehow cast DataTable to DataSet?
>>
>
>No, but you can add a DataTable to a DataSet (as long as the DataTable doesn't already belong to another DataSet), ex:
>
>
>DataSet ds = new DataSet();
>// Retrieve the table from wherever
>DataTable table = new DataTable("TableName");
>ds.Tables.Add(table);
>
>
>If it's already part of a DataSet (ex. you can tell by checking to see if the tables DataSet property is null or not), you'll get an error if you try assigning it to another DataSet. If that's the case, you can copy the DataTable, then add the copy:
>
>
>if (table.DataSet != null)
>{
> DataTable newTable = table.Copy()
> ds.Tables.Add(newTable);
>}
>
If it's not broken, fix it until it is.
My Blog