|
Monday, 19 December 2011 01:02 |
In ADO.NET 2.0, the DataView Object has a new method called ToTable, which allows you to create a new table based on data in the DataView.
Here is an example that we used above that creates a new DataTable listing Brazilian Contact Names only:
//Filtered records
DataView dv = new DataView(GetTable(),"Region = 'SP' and Country = 'Brazil'", "ContactName", DataViewRowState.CurrentRows);
//Create new table based on filtered records
DataTable newTable = dv.ToTable("BrazilianContactNames", true, new string[] { "ContactName" });
//Bind grid with only filtered records
dataGridView1.DataSource = newTable.DefaultView;
 Read more: |