Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Identify a sorted column
Message
General information
Forum:
ASP.NET
Category:
WebForms
Miscellaneous
Thread ID:
00867190
Message ID:
00867371
Views:
19
Hi Troy,

Here is some sample code that will add the up or down arrow to the datagrid for the sort column. The best way to get ultimate control over this is to use the ItemCreated event of the DataGrid. When the item is created, a check is made to see if it is actually the header (since this event fires for header, footer, pager, etc.). If the current item/column is the one the grid is sorted by, then add a label control with the up/down arrow in the webding font, giving the directional arrow indicating the sort-direction. Instead of a label control, you could use an image control.
Private Sub ReportGrid_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles MyBase.ItemCreated

  If e.Item.ItemType = ListItemType.Header Then
    Dim i As Integer = 0
    For i = 0 To e.Item.Controls.Count - 1
      If Attributes("SortExpression") = Columns(i).SortExpression Then
        Dim ArrowLabel As New Label()
        ArrowLabel.Font.Name = "webdings"
        ArrowLabel.Font.Size = FontUnit.XSmall  
        If Attributes("SortAsc") = "True" Then
          ArrowLabel.Text = " 6"
        Else
          ArrowLabel.Text = " 5"
        End If
        ReportHeader.Controls.Add(ArrowLabel)
      End If
    Next
  End If
End Sub
>I can't imaging this being difficult, but I have not been having any luck on a solution of making the column that represents the current sort order of an ASP.NET grid stand out. I want the column header to somehow stand out if that column represents column header that was last clicked and therefore drives the sort order.
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform