Bhaurao Devkar Bhaurao Devkar - 1 year ago 163 Question

How to sort my DATATABLE

All data shows in

, so how to get sorted data in
ascending order

Dim dt_item As DataTable = CType(Cache("ITEMS"), DataTable)


Answer Source

This may help you sortExp can be field on which based the sort should be performed filterExp that should evaluate to true or false. assuming the following fields

Dim filterExp As String = "Status = 'Active'"
Dim sortExp As String = "Item"
dt_item.Select(filterExp, sortExp, DataViewRowState.CurrentRows)

The above code shows how to filter and sort the data table dt_item. The filter expression selects Item whose status is active. The sort expression causes the results to be sorted by the Item column

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download