DataView.ToTable() Method

Posted Tuesday, March 8, 2005 8:32 AM by C-Dog's .NET Tip of the Day
Many times in the past I have been faced with trying to convert a DataView back to a DataTable.  Well in ADO.NET today, that takes quite a bit of work.  If you are wondering why you would ever want to do this.  It is typically easier to perform sorting and filtering and what not with a DataView over a DataTable (although you can do both with a DataTable).  There is also a bit of a performance improvement when using a DataView.  However, once you do your work with a DataView, you may want to convert that back to a DataTable so that you can make use of typed schemas or send it back to a database, etc.
To alleviate that issue ADO.NET 2.0 introudces the ToTable method on the DataView object.  Overloaded versions of the ToTable method allow you to specify which columns get written to the new DataTable as well as the table name.  This new method will make this task much easier in the future.

Read the complete post at