Converting Dataview to a Datatable.
-
Hi, I have a datatable ParentTable that contains 100 records I created a Dataview that selects only UK users Dataview dvUK=ParentTable.DefaultView(); dvUK..RowFilter= "Country='UK'"; now in my dataiview dvUK have 30 records I want to copy all these 30 records to some other table(dtChildUK) that have same structures as the ParentTable DataTable dtChildUK=ParentTable.Clone(); How to copy all the 30 rows ( rows from dataview) to dtChildUK
-
Hi, I have a datatable ParentTable that contains 100 records I created a Dataview that selects only UK users Dataview dvUK=ParentTable.DefaultView(); dvUK..RowFilter= "Country='UK'"; now in my dataiview dvUK have 30 records I want to copy all these 30 records to some other table(dtChildUK) that have same structures as the ParentTable DataTable dtChildUK=ParentTable.Clone(); How to copy all the 30 rows ( rows from dataview) to dtChildUK
-
Try this after applying the filter to the DataView:
foreach (DataRowView rowView in dvUK) { dtChildUK.Rows.Add(rowView.Row); }
Fernando Mendes Senior .NET Developer, Architect
Thank you
-
Hi, I have a datatable ParentTable that contains 100 records I created a Dataview that selects only UK users Dataview dvUK=ParentTable.DefaultView(); dvUK..RowFilter= "Country='UK'"; now in my dataiview dvUK have 30 records I want to copy all these 30 records to some other table(dtChildUK) that have same structures as the ParentTable DataTable dtChildUK=ParentTable.Clone(); How to copy all the 30 rows ( rows from dataview) to dtChildUK
Hello You can use only this method of dv:
DataTable dtChildUK=dvUK.ToTable();
Simple and efficient. Be Happy :-DSyed Shahid Hussain