convert a dataview to a dataset dataview to datatable
public static DataTable DataViewAsDataTable( DataView dv)
{
DataTable dt = dv.Table.Clone();
foreach (DataRowView drv in dv)
dt.ImportRow(drv.Row);
return dt;
}
DataSet dsFiltered = new DataSet(); //create a new dataset
dsFiltered.Tables.Add(AppUtil.DataViewAsDataTable (dvResult) ); //fill the dataset with the sorted results

11 Comments:
Good, it is very helpful
Is iterating through the dataviewrows really the only way to do this?
I haven't found a better way to do it (after 15 minutes of searching) so I'm guessing there isn't one. But it seems a bit funny that you have to iterate through the datarows. Thanks anyway - this is the best solution I found so far.
Software Dorset
thanks!
This is better me thinks..
ds.Tables.Add(dv.Table.Copy());
Thaks dude...i couldnt figure out a better one...
An easier way:
DataTable newOne = dv.ToTable();
Available in .NET 2.0 and above only.
Thank you, dorked around with this forever... was trying to avoid iteration, but apparently that is the only choice in 1.1
Thanks a lot mate...
this solution was exactly that i was looking for....Hat's OFF
awesome thank you. i guess there is no dv.toTable() in 1.1. 2.0 makes it easier.
Thanks friend. I tried multiple ways to create dataset from Dataview.. Yours is the best one..
You know ,I have some wonderland Gold,and my friend
also has some wonderland online Gold,do you kouw they
have the same meaning,Both of them can be called
wonderland money,I just want to
buy wonderland Gold,because there are many
cheap wonderland online Gold
Post a Comment
<< Home