Bhaurao Devkar Bhaurao Devkar - 7 months ago 70
Vb.net Question

How to sort my DATATABLE

All data shows in

dt_item
from
cache
, so how to get sorted data in
ascending order
data.

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


Thanks.

Answer

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