Export (0) Print
Expand All
Expand Minimize
1 out of 2 rated this helpful - Rate this topic

ListView::Sort Method

Sorts the ListView control, depending on the specified sort expression and direction.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)
public:
virtual void Sort(
	String^ sortExpression, 
	SortDirection sortDirection
)

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.

ExceptionCondition
InvalidOperationException

The ListView control is bound to a data source control, but the DataSourceView object that is associated with the data source is nullptr.

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.

This method raises the Sorted and Sorting events.

The following example shows how to use the Sort method to programmatically sort the ListView control by multiple data fields.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.