This sample demonstrates how to sort tables by different columns and also how to avoid sorting. The sample includes options to sort the table’s content by CustomerName, ContactName and ContactTitle.
Features:
Uses a data set with Customer's tables
Data set created at design-time
Includes options to sort the table’s content by CustomerName, ContactName and ContactTitle
Demonstrates different ways to sort and avoid sorting:
By setting the SortBehavior property to None can avoiding sorting on columns
Sorting by double click can be achieved by setting the SortBehavior property to DoubleClick
Sorting by single click can be achieved by setting the SortBehavior property to SingleClick
Here is the code to sort the values by CompanyName:
this.gridDataBoundGrid1.SortColumn(this.gridDataBoundGrid1.Binder.InternalColumns["CompanyName"].Position );
Here is the code to avoid column sort:
this.gridDataBoundGrid1.SortBehavior = GridSortBehavior.None;
Here is the code to sort by single click
this.gridDataBoundGrid1.SortBehavior = GridSortBehavior.SingleClick;