This article's text has not been updated to reflect these changes.After you've finished this article, read Improving the Sort Arrows Grid View Control, which discusses the enhancements in more detail. NET version 2.0 was released, I wrote a book and dozens of articles on the Data Grid control, which was the most functional data Web control in the ASP. The Grid View can be bound to data source controls like the Sql Data Source and Object Data Source, and paging, sorting, editing, and deleting can be implemented without having to write a single line of code.To create a custom server control that extends an existing control, create a public class that derives from the Web control that you want to extend.I created a class named method that is called each time a row is added to the Grid View, including the header row.My first thought was to override this method and, for the header row, enumerate the fields and update each column's appropriately (removing any image markup first, and then adding the up or down arrow image for the sorted row).However, if you attempt to update a Grid View's field's properties during the databinding stage, the field reports to the Grid View that its state has been changed and that the data needs to be re-bound.If you want to use custom arrow images, specify the URL either declaratively or programmatically. The demo page includes a checkbox that allows you to toggle between using the default arrow images and custom ones.
NET page very similar to that used for the Data Grid.Therefore, I embedded an up and down arrow image into the properties.Consequently, the grid displays the standard up and down arrow images (see the first screen shot below).However, I decided that instead of having to write code for each page where I wanted to show up and down arrow images, I decided to instead build a custom server control that extended the Grid View control.I could then bake in the necessary code by overriding the necessary Grid View methods.For more information on sorting with the Grid View, along with a downloadable demo, check out the Paging and Sorting Report Data tutorial.