Easiest way to copy a dataview to a datatable in C#?

Ravedave picture Ravedave · Apr 20, 2009 · Viewed 50.5k times · Source

I need to copy a dataview into a datatable. It seems like the only way to do so is to iterate through the dataview item by item and copy over to a datatable. There has to be a better way.

Answer

Jose Basilio picture Jose Basilio · Apr 20, 2009
dt = DataView.ToTable()

OR

dt = DataView.Table.Copy(),

OR

dt = DataView.Table.Clone();