Telerik ASP.NET GridButtonColumn won't sort

Making a Telerik RadGrid Button Column Sortable Using a Template Column

Sorting in Telerik’s ASP.NET AJAX RadGrid works smoothly—until you introduce a GridButtonColumn. Because button columns don’t bind directly to a data field, the grid has nothing concrete to sort on. The practical fix is to replace the button column with a GridTemplateColumn that looks and behaves like a button column, but sorts on a real field from your data source. It’s simple, predictable, and uses RadGrid’s built-in sorting pipeline.

 

<telerik:GridTemplateColumn HeaderText="Project" AllowSorting="true" SortExpression="TRACKINGno">
    <ItemTemplate>
        <asp:linkbutton runat="server"   Text='<%# Eval("TRACKINGno") %>' PostBackUrl='<%# "/Project/" & Eval("TRACKINGno") %>'></asp:linkbutton>
    </ItemTemplate>
</telerik:GridTemplateColumn>

 

This approach gives you a clickable link that behaves like your original button column, while still allowing RadGrid to sort on TRACKINGno. There is no custom JavaScript, no manual sorting logic, and no extra event wiring required.

How the sorting actually works

The key is the SortExpression:

SortExpression="TRACKINGno"

Because TRACKINGno exists in your data source, RadGrid can:

  • Generate SQL: Build the correct ORDER BY clause (or equivalent) when rebinding.
  • Track state: Maintain sort direction across paging and postbacks.
  • Update UI: Show the sort glyph and reflect the current sort order.

The template column is just a container. It controls how the cell is rendered, but it does not interfere with the sorting logic. RadGrid still sorts on the underlying field, and your users see a clickable project link in the UI.

When this pattern is a good fit

This template-column pattern is ideal when you need:

  • Navigation links: A column that navigates to a detail page (for example, /Project/{TRACKINGno}).
  • Interactive cells: Buttons or links inside a sortable column instead of plain text.
  • Server-side behavior: A clean, server-side solution that works with NeedDataSource and standard RadGrid features.
  • Consistency: Sorting that behaves like any other bound column in the grid.

If you are already using NeedDataSource, custom paging, or multiple template columns, this approach drops in without any special handling. The grid still binds and sorts using the same data source logic you already have.

Alternative: Using a command instead of PostBackUrl

If you prefer to handle navigation or actions in code-behind instead of using PostBackUrl, you can switch the link to use a command:

<asp:LinkButton runat="server"
                Text='<%# Eval("TRACKINGno") %>'
                CommandName="SelectProject"
                CommandArgument='<%# Eval("TRACKINGno") %>'>
</asp:LinkButton>

Then handle the command in your RadGrid’s ItemCommand event:

Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles RadGrid1.ItemCommand
    If e.CommandName = "SelectProject" Then
        Dim tracking = e.CommandArgument.ToString()
        Response.Redirect("/Project/" & tracking)
    End If
End Sub

This keeps all navigation logic in one place (the code-behind), while the column remains fully sortable on TRACKINGno.

Conclusion

Telerik’s GridButtonColumn looks convenient, but it cannot participate in sorting because it is not bound to a real data field. By switching to a GridTemplateColumn with a SortExpression that matches your data source field, you get the best of both worlds: a clickable link or button in the UI and full RadGrid sorting support. It is a small change in markup that removes a lot of confusion and keeps your grid behavior consistent and intuitive.


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences