views:

96

answers:

1

Hi I am using the following to sort results of a datatable returned by a tableadapter

 Dim spots = myDataTable.Where(Function(t) t.UserID = 1).OrderByDescending(Function(t) t.Title)

The thing is, I also need to OrderByAscending the very same datatable. But as far as I see, it is not giving it as an option. I am sure there is a way to sort it ascending. Can anyone show me how?

+2  A: 

OrderBy will order in ascending order.

Dim spots = myDataTable.Where(Function(t) t.UserID = 1) _
                       .OrderBy(Function(t) t.Title )

Or, if you need to sort by a second value, use ThenBy

Dim spots = myDataTable.Where(Function(t) t.UserID = 1) _
                       .OrderByDescending(Function(t) t.Title ) _
                       .ThenBy(Function(t) t.OtherField )
tvanfosson