Sorting Columns
The DataGrid offers both built-in and custom paging solutions. It also offers simple solutions for enabling column sorting in a rendered table. Using the built-in sorting features of the DataGrid, you easily can allow your Web site visitors to click on column headings to re-sort the DataGrid.
The sorting functionality requires you to handle the sorting of the data, but it handles the tracking of which column to sort by. Much like paging, sorting is enabled by setting the DataGrid.AllowSorting property to True. This tells the DataGrid that you want the column headings to be links that the user can click on to re-sort the DataGrid.
Once AllowSorting is set to True, you need to specify the OnSortCommand event handler. In the event ...
Get Programming Data-Driven Web Applications with ASP.NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.