When there's no time for best practices
There's no way to automatically sort a DataTable after it's populated.
A way around this is to sort the DefaultView of the DataTable (or any other DataView associated with the DataTable).
You can achieve this using the Sort property of the DataView. This is a string which specifies the column (or columns) to sort on, and the order (ASC or DESC).
myDataTable.DefaultView.Sort = "myColumnOfChoice DESC";
The DefaultView can now be used as datasource for stuff or to do whatever you need it for.
Worked like a charm. Thanks!
thanks man. worked awesomely.
Thanks.. This is helpful..
Thanks a ton
MyStrongDataSet ds = new MyStrongDataSet();ds.MyTable.DefaultView.Sort = "MySortColumnName";Give that a try as well.
Sweet, thanks for the tip
Post a Comment