Have some read in data (from excel file) in a DataTable and now I want to filter this and copy only specific columns to the other one!
dataTable format:
some data
ColA|ColB|ColC
xxxx|xxxx|xxxx
some data
some data
represents other table data not related to ColA-ColC
How can I copy ColA-ColC with xxxx to the new DataTable?
Thx
You can simply do it by using DataView.ToTable() :
System.Data.DataView view = new System.Data.DataView(yourOriginalTable);
System.Data.DataTable selected =
view.ToTable("Selected", false, "col1", "col2", "col6", "col7", "col3");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With