Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge multiple dataviews into one?

I have three dataviews (dataview1, dataview2, and dataview3). These are of type System.Data.DataView, and all three have the same columns. Is there an easy way to merge them into one, so I have one dataview with rows from dataview1, followed by dataview2, and then dataview3?

like image 286
Prabhu Avatar asked Sep 30 '11 17:09

Prabhu


2 Answers

Dim dataview1 As DataView = new DataView()
Dim dataview2 As DataView = new DataView()

'' given the tables are not null you can then merge like this

dataview1.Table.Merge(dataview2.Table)
like image 125
Dennis Traub Avatar answered Oct 11 '22 18:10

Dennis Traub


DataTable datatableMerge = dataview1.ToTable();
datatableMerge.Merge(dataview2.ToTable());

The result includes only the rows according to the the DataViews' Filters.

like image 42
Yang CC Avatar answered Oct 11 '22 17:10

Yang CC