RadGrid for ASP.NET

RadGrid Send comments on this topic.
AllowSorting Property
See Also  Example
Telerik.WebControls Namespace > RadGrid Class : AllowSorting Property


Gets or sets a value indicating whether the sorting feature is enabled.   

 

Namespace: Telerik.WebControls
Assembly: RadGrid (in RadGrid.dll)

Syntax

Visual Basic (Declaration) 
Public Overridable Property AllowSorting As Boolean
Visual Basic (Usage)Copy Code
Dim instance As RadGrid
Dim value As Boolean
 
instance.AllowSorting = value
 
value = instance.AllowSorting
C# 
public virtual bool AllowSorting {get; set;}

Return Value

true if the sorting feature is enabled; otherwise, false. The default is false.

Example

The following code example demonstrates how to use the AllowSorting property to enable sorting in a Telerik RadGrid control when automatically generated columns are used.
Visual BasicCopy Code
<%@ Page Language="VB" %>

<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>

<!DOCTYPE html Public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <rad:RadGrid
            DataSourceID="SqlDataSource1"
            ID="RadGrid1"
            runat="server"
            AllowSorting="true">
        </rad:RadGrid>
        <!-- This example uses Microsoft SQL Server And connects -->
        <!-- To the Northwind sample database. Use an ASP.NET -->
        <!-- expression To retrieve the connection String value -->
        <!-- from the Web.config file. -->
        <asp:SqlDataSource
            ID="SqlDataSource1"
            runat="server"
            ConnectionString="<<see cref="!:NorthwindConnectionString">$ ConnectionStrings</see>>"
            SelectCommand="SELECT [CustomerID], [ContactName], [CompanyName] FROM [Customers]">
        </asp:SqlDataSource>
    </div>
    
</body>
</html>

Remarks

When a data source control that supports sorting is bound to the Telerik RadGrid control, the Telerik RadGrid control can take advantage of the data source control's capabilities and provide automatic sorting functionality.

To enable sorting, set the AllowSorting property to true. When sorting is enabled, the heading text for each column field with its SortExpression property set is displayed as a link button.

Clicking the link button for a column causes the items in the Telerik RadGrid control to be sorted based on the sort expression. Typically, the sort expression is simply the name of the field displayed in the column, which causes the Telerik RadGrid control to sort with respect to that column. To sort by multiple fields, use a sort expression that contains a comma-separated list of field names. You can determine the sort expression that the Telerik RadGrid control is applying by using the SortExpression property. Clicking a column's link button repeatedly toggles the sort direction between ascending and descending order.

Requirements

Supported in: 3.0, 2.0, 1.1, 1.0 .NET Framework

See Also

Reference

RadGrid Class
RadGrid Members

Telerik RadGrid Manual

Sorting Expressions