Sunday, November 14, 2010

Sorting dataview on multiple columns

Sorting multiple columns in the dataview we just need to separate the columns with a comma. To define the sort direction we can use ASC or DESC after the column name. Here is an example on how to sort a dataview in multiple columns
// Get the DefaultViewManager of a DataTable.
DataView view = DataTable1.DefaultView;
// By default, the first column sorted ascending.
view.Sort = "LastName ASC, FirstName ASC, Age DESC";

No comments:

Post a Comment