Shaun Morehammered Denovan Shaun Morehammered Denovan - 2 months ago 12 Question

VB.NET table.sort with multiple columns

I have the following but need to add more columns to filter by. I am getting errors with the syntax I am trying.

Dim ldv1 As System.Data.DataView
ldv1 = tbl1.DefaultView
ldv1.Sort = (tbl1.Columns(0).ColumnName) & " Asc" <-- I want to add to this

I am trying to do something like this but failing:

ldv1.Sort = (tbl1.Columns(0).ColumnName) & " Asc",(tbl1.Columns(1).ColumnName) & " Asc"


ldv1.Sort = (tbl1.Columns(0).ColumnName), (tbl1.Columns(1).ColumnName) & " Asc"

Neither seems to be the correct way. How do I sort by more columns?


Add a , inside the string after the first Asc.

ldv1.Sort = tbl1.Columns(0).ColumnName + " Asc, " + tbl1.Columns(1).ColumnName + " Asc"