aspxtreme

Adding Sorting to a GridView Control

Controls You Can Use on Web Forms   ASP.NET Data Controls   GridView Control


The GridView control provides a default sorting functionality without requiring any coding. If the default sort behavior is not adequate for the need, though, the GridView provides for customization of the default sort functionality.

Specifying Default Sorting

With the default setting, all columns in the grid are sortable. The headers for all columns are automatically rendered as LinkButton controls, that users can click to arrange the ordering of the grid contents by that column.

To specify default sorting

  1. Set the GridView control's AllowSorting property.
    <asp:GridView id="myGrid" runat="server"
       datasourceid="customers"
       allowsorting=true
       ...
    >

    or simply

    <asp:GridView id="myGrid" runat="server"
       datasourceid="customers"
       allowsorting
       ...
    >
Run Sample | View Source



Books and more ...


Suggested Reading

Need a break ?



Previous page Back to top Next page

Check out related books at Amazon

© 2000-2008 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support aspxtreme