I have a list view which is bound to a DataTable source.
The sorting works, kinda.
For text is fine but not so much for numbers.
For example if I sort 1-12 descending I get 9,8,7,6,5,4,3,2,12,11,10,1.
How to get the proper sequence?
I am using:
lvPos.Sort("Position", SortDirection.Descending);
You’re likely going to have to do the sorting yourself instead of relying on ListView’s sort method.
If you’re sorting just using code, this is very easy. Just shove your DataTable into a DataView and use the DataView’s Sort method. Then bind to your DataView instead of your DataTable.
If you’re sorting from the ListView’s sort methods (i.e. you have something in the page triggering the ListView.Sorting/Sorted events), then you would have to hook on to the Sorting event and cancel it. Follow up with the previous technique of shoving the DataTable into a DataView (or re-use the DataView!), sort by the new expression, and rebind your data.