Click here to Skip to main content
Click here to Skip to main content

Tagged as

Converting DataView to Table

, 24 Dec 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Creating a DataTable from a DataView - DataView.ToTable()
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;
 
For more details, please click here[^]
 
Thanks,
Imdadhusen

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Sunasara Imdadhusen
Software Developer (Senior) Infostretch Ahmedabad-Gujarat
India India
Aspiring for a challenging carrier wherein I can learn, grow, expand and share my existing knowledge in meaningful and coherent way.

sunaSaRa Imdadhusen
 
AWARDS:
  1. 1st Best Asp.Net article of SEP 2010
  2. 2nd Best Asp.Net article of MAY 2011
 
Read More Articles...
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
GeneralMy vote of 5 PinmemberSavalia Manoj M7-Nov-12 1:13 
GeneralRe: My vote of 5 PinprofessionalSunasara Imdadhusen22-Apr-14 3:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 24 Dec 2010
Article Copyright 2010 by Sunasara Imdadhusen
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid