Hey,
Can I do something like this?
Dim dt As DataTable = MyDataSet.Tables(0)
Dim dv As DataView = New DataView(dt)
dv.RowFilter = ("start_dt")
I want to sort by date. I have coulmn start_dt. I tried this but it throws error.
I am using vb.net
Thanks,
That would be because RowFilter is exactly that - a filter consequently you would need to use dv.RowFilter = "start_dt = 'whatever is in start_dt'"
What you're looking for is dv.Sort
- Dim dt As DataTable = MyDataSet.Tables(0)
-
Dim dv As DataView = New DataView(dt)
-
dv.Sort = "start_dt DESC"
You can substitute DESC for ASC if you wish to change the sort order, you can also use a comma to delimit - thus if you want to sort on multiple columns you can do that also:
dv.Sort = "<Column Name> [ASC|DESC]...[, Column
n [ASC|DESC]"
Which basically translated =
dv.Sort = "Column1 ASC, Column2 DESC, Column3 DESC, Column4 ASC" etc etc.
Hope that helps