Search code examples
c#datatabledataview

How to copy a DataView to a DataTable in C#


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 each item over to the DataTable.

Is there a way to do it without looping through the DataView?


Solution

  • dt = DataView.ToTable()
    

    OR

    dt = DataView.Table.Copy()
    

    OR

    dt = DataView.Table.Clone()