The DefaultView property of a DataTable is a DataView. When you bind a control to a DataTable you are actually binding it to this DataView. You can set the RowFilter, RowStateFilter and, most interestingly for you, Sort properties of the DataView to affect the data displayed in the control. The Sort property of the DataView class takes a valid SQL ORDER BY clause without the words "ORDER BY" at the start. Here is an example of sorting a bound DataGrid by the "Name" column:
Code:myDataGrid.DataSource = myDataTable
myDataTable.DefaultView.Sort = "Name ASC"
The DataViewManager class is to the DataSet as the DataView class is to the DataTable. A DataSet has a DefaultViewManager property that is a DataViewManager object.
Enter your message below
Sign in or Join us (it's free).