• Uncategorized

How to sort GridView?

In this article I will discuss how to sort columns in grid and more. At the end it will help answer some very frequently asked questions like following.

  • How to sort DataGrid in ASP.Net?
  • How to sort GridView?
  • How to show sort direction image in column header of GridView or DataGrid?
  • How to keep track of sorting direction and sort expression while sorting GridView?

Along with getting answers to these question I will also discuss some of the issues with implementation of sorting in GridView. And one of the very frequently brought up issue is that SortDirection property of GridViewSortEventArgs is always set to Ascending.

Specifying Sorting Attributes For GridView

To enable sorting for GridView set Sorting attribute for the control to True and if you are specifying event handlers for controls on page itself then set the event handler function for OnSort event of the control. The following code snippet from ASPX page shows how these attributes are set.

Deepak Kamboj

Deepak Kamboj is a Solution Architect and Technology Enthusiast, located at Redmond, WA, having 14+ years of hands on experience in the IT industry.

You may also like...