Home Ask Login Register

Developers Planet

Your answer is one click away!

Prabhagaran P February 2016

How to insert data into datatable from datagrid without using ItemSource in Wpf?

I have a Datagrid which has DataView as ItemSource . Actually that DataGrid will not display all data which is in Dataview. i.e if dataview has 21 column but datagrid displayed only 13 column.Now i want to select those 13 columns and add it to New DataTable. I dont know how to do this. Please help me. Thankyou


Tim Schmelter February 2016

You can use DataView.ToTable:


string[] columnNames = { " Col1", "Col2", "...", "Col13" };
DataTable newTable = view.ToTable("TableName", false, columnNames);


Dim columnNames = { " Col1", "Col2", "...", "Col13" }
Dim newTable As DataTable = view.ToTable("TableName", False, columnNames)

Post Status

Asked in February 2016
Viewed 2,674 times
Voted 14
Answered 1 times


Leave an answer

Quote of the day: live life