Edit this page


To enable sorting for GridHyperLinkColumn and GridTemplateColumn, you need to set appropriate SortExpression values for those columns.

  • When using GridHyperLinkColumn, the SortExpression value should match the DataTextField property of the column.

  • When using GridTemplateColumn, the SortExpression value should match the data field you want to sort on (typically the field a control in the template is bound to).

<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AllowSorting="True"
  <MasterTableView AutoGenerateColumns="false" AllowSorting="true">
      <telerik:GridHyperLinkColumn DataTextField="Country" NavigateUrl="http://www.telerik.com"
        HeaderText="Country" SortExpression="Country" />
      <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="City" SortExpression="City">
          <%# Eval("City") %>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT TOP 10 [Country], [City] FROM [Customers]">

You can add a sort button to a template in the grid. When adding a sort button, set the CommandName property to "Sort" and the sort expression as the CommandArgument for the button. RadGrid can then handle the sorting automatically when the user clicks the button.

<telerik:GridTemplateColumn SortExpression="CompanyName">
      <asp:Button id="Button1" runat="server"
         Title="Sort by CompanyName"
         CommandArgument='CompanyName' />
Is this article helpful? No Yes
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article