ListView::Sort Method (String^, SortDirection)
Sorts the ListView control, depending on the specified sort expression and direction.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
Parameters
- sortExpression
-
Type:
System::String^
The sort expression to sort the ListView control with.
- sortDirection
-
Type:
System.Web.UI.WebControls::SortDirection
One of the SortDirection values.
| Exception | Condition |
|---|---|
| InvalidOperationException | The ListView control is bound to a data source control, but the DataSourceView object that is associated with the data source is null. |
Use the Sort method to programmatically sort the data that is displayed in the ListView control by using the specified sort expression and direction. The sort expression specifies the column or columns to sort with. To sort multiple columns, create a sort expression that contains a comma-separated list of field names. The sort direction indicates whether sorting is performed in ascending or descending order.
You typically use this method when you want to sort the contents of the ListView control from outside the control, such as from a different control on the page. This method is also used to programmatically set a default sort order for the ListView control when it is first rendered.
Available since 3.5