1 Previous Next 

DataTable: Sort/Filter


Sometimes is asked how to sort/filter a datatable for external use in a dataset. Here a sample how that is easy to do. (In version 2005 there is a standard method for this DataView.ToTable(4 times overloaded)
Dim dv As New DataView(dt)
dv.Sort = "bla"
dv.RowFilter = "bla = 1"
Dim dtnew As DataTable = dt.Clone
For Each dvr As DataRowView In dv
dtnew.ImportRow(dvr.Row)
Next
dt.Clear()
dt = dtnew.Copy



1 Previous Next