[VB.Net]
dt.DefaultView.Sort = "ColumnName" 'normal DataTable
ds.Tables("TableName").DefaultView.Sort = "ColumnName" 'DataTable in DataSet
[C#]
dt.DefaultView.Sort = "ColumnName" 'normal DataTable
ds.Tables["TableName"].DefaultView.Sort = "ColumnName" 'DataTable in DataSet
With this snippet you don't "physically" order the content of the DataTable but it's default view. But for data visualization purpose and other the result is the same.
Using this DataTable, for example, as datasource for a GridView the list will be sorted based of the used criteria (ColumName).
No comments:
Post a Comment