DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2006
    Posts
    17

    Header style of datagrid to bold

    Header style of datagrid not changed to bold for a column if i put sort expression="columnname", any idea how to make the header to bold and make the font to arial.

    Thanks

  2. #2
    Join Date
    May 2006
    Posts
    64
    Did you try Property builder for datagrid?

    http://www.programmingknowledge.com/

  3. #3
    Join Date
    Mar 2010
    Posts
    1
    It's been a very long time since the question, but as I searched a lot and did not find any answers, I will post what I've done to solve that subject.

    I'm not sure that it's the easiest solution or that it is very optimized but it works.

    Code:
    Public Sub MyList_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles myList.ItemDataBound
    
    If myList.AllowSorting = True And e.Item.ItemType = ListItemType.Header Then
                For Each dgc As DataGridColumn In myList.Columns
                    If dgc.SortExpression = ViewState("sortColumn").ToString() Then
                        For Each tc As TableCell In e.Item.Cells
                            If tc.Controls.Count > 0 Then
                                If CType(tc.Controls(0), LinkButton).Text = dgc.HeaderText Then
                                    tc.Font.Bold = True
                                    Exit For
                                End If
                            End If
                        Next
                        Exit For
                    End If
                Next
            End If        
    End Sub
    
        Private Sub MyList_SortCommand(ByVal sender As Object, ByVal e As DataGridSortCommandEventArgs) _
            Handles myList.SortCommand
    
            If (ViewState("sortColumn").ToString() = e.SortExpression) Then
                If ViewState("sortOrder").ToString() = "Desc" Then
                    ViewState("sortOrder") = "Asc"
                Else
                    ViewState("sortOrder") = "Desc"
                End If
            Else
                ViewState("sortColumn") = e.SortExpression
                ViewState("sortOrder") = "Asc"
            End If
    
            BindGrid()
        End Sub

Similar Threads

  1. Replies: 0
    Last Post: 09-02-2005, 07:28 PM
  2. Replies: 4
    Last Post: 08-16-2004, 07:33 PM
  3. DataGrid Header in Dynamically Added Template Columns
    By David Hirschfeld in forum ASP.NET
    Replies: 0
    Last Post: 01-05-2003, 11:49 AM
  4. Is there guidelines for proper use of DataGrid
    By Thomas Eyde in forum .NET
    Replies: 8
    Last Post: 08-01-2002, 06:43 PM
  5. Threading and the .NET Datagrid
    By McCleud in forum .NET
    Replies: 2
    Last Post: 08-01-2002, 10:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links