New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Sorting Overview
RadListView possesses sorting capabilities that are similar to these, offered by RadGrid, so the developers who are familiar with Telerik controls will get used to RadListView easily.
Implementing sorting is very easy - you should add a SortExpression object to the SortExpressions collection as demonstrated on the following example.
C#
protected void Button1_Click(object sender, EventArgs e){
RadListViewSortExpression expression = new RadListViewSortExpression();
RadListView1.SortExpressions.Clear();
expression.FieldName = "myFieldName";
expression.SortOrder = RadListViewSortOrder.Descending;
RadListView1.SortExpressions.AddSortExpression(expression);
RadListView1.Rebind();
}
Sorting by multiple fields as well as the natural sorting could be enabled by setting the corresponding properties - AllowMultiFieldSorting and AllowNaturalSort.
To facilitate the users that need a string representation of the sorting expression, we exposed the GetSortString method:
C#
Label1.Text = RadListView1.SortExpressions.GetSortString();
When binding RadListView to ObjectDataSource control you should set the OverrideDataSourceControlSorting property to true