Improving the Sort Arrows GridView Control
Posted by: 4GuysFromRolla.com Headlines,
on 06 Feb 2008 |
View original | Bookmarked: 0 time(s)
While the GridView control offer built-in, bi-directional sorting support, there is no visual feedback as to what column the data is sorted by.
To remedy this shortcoming, I showed how to create a custom server control that extended the GridView class and automatically added arrow up and down
images to the appropriate column header, thereby clearly showing what column the data was sorted by and whether the data was sorted in ascending or
descending order. Read Extending the GridView to Include Sort Arrows for more
information on this technique.

Since publishing that article, I have received a lot of great feedback and suggestions for improving the control. 4Guys reader Richard Deeming proposed
a better technique for adding the arrow images to the appropriate GridView header cell, one that removed the hacks that my approach required. Another
great suggestion came from Tom Mason, who proposed using a differing CSS class in lieu of <img> elements in the header. Tom's ideas
prompted me to add two new properties to the custom GridView control: SortAscendingStyle and SortDescendingStyle. Use these
properties to customize the appearance of the sorted header cell.
Read on to learn more about these enhancements!
Read More >