sort image or style on data grid

Discussion in 'ASP .Net' started by Brian Henry, Jul 14, 2004.

  1. Brian Henry

    Brian Henry Guest

    is there a way to put a style or marker image on the header of a data grid
    in asp.net to mark that this is the column being sorted on? thanks
     
    Brian Henry, Jul 14, 2004
    #1
    1. Advertising

  2. Hi Brian,

    As for your questions on marking a certain columns' header in webform
    datagrid when the certain columns is being sorted on, here are my
    suggestions:

    All the WebForm DataGrid's Column are dervied from the
    System.Web.UI.WebControl.DataGridColumn base class. This class has three
    properties which can help set the column's header style feature, they are

    HeaderImageUrl========== Gets or sets the location of an image to display
    in the header section of the column.

    HeaderStyle ============Gets the style properties for the header section of
    the column.

    HeaderText============ Gets or sets the text displayed in the header
    section of the column.

    Here is the reference in MSDN:
    #DataGridColumn Properties
    http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebUIWebContro
    lsDataGridColumnPropertiesTopic.asp?frame=true

    And the "HeaderStyle" property is especially good since it contains many
    sub members such as BackColor or BorderColor....

    Thus, in the DataGrid's SortCommand event, we can retrieve the certain
    columns reference from the
    DataGrid.Columns collection and set any of the above three properties of
    the sorted column. How do you think of this?


    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
     
    Steven Cheng[MSFT], Jul 14, 2004
    #2
    1. Advertising

  3. Brian Henry

    Brian Henry Guest

    I know about the properties of the column header, but how I get which column
    it is working with from the sort event I'm not sure of


    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Brian,
    >
    > As for your questions on marking a certain columns' header in webform
    > datagrid when the certain columns is being sorted on, here are my
    > suggestions:
    >
    > All the WebForm DataGrid's Column are dervied from the
    > System.Web.UI.WebControl.DataGridColumn base class. This class has three
    > properties which can help set the column's header style feature, they are
    >
    > HeaderImageUrl========== Gets or sets the location of an image to display
    > in the header section of the column.
    >
    > HeaderStyle ============Gets the style properties for the header section

    of
    > the column.
    >
    > HeaderText============ Gets or sets the text displayed in the header
    > section of the column.
    >
    > Here is the reference in MSDN:
    > #DataGridColumn Properties
    >

    http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebUIWebContro
    > lsDataGridColumnPropertiesTopic.asp?frame=true
    >
    > And the "HeaderStyle" property is especially good since it contains many
    > sub members such as BackColor or BorderColor....
    >
    > Thus, in the DataGrid's SortCommand event, we can retrieve the certain
    > columns reference from the
    > DataGrid.Columns collection and set any of the above three properties of
    > the sorted column. How do you think of this?
    >
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    > Get Preview at ASP.NET whidbey
    > http://msdn.microsoft.com/asp.net/whidbey/default.aspx
    >
    >
    >
    >
     
    Brian Henry, Jul 14, 2004
    #3
  4. Hi Brian,

    Thanks for your response. As for how to get the column that is on sorting
    in SortEvent, this is done by the
    System.Web.UI.WebControls.DataGridSortCommandEventArgs e
    argument pass into the DataGrid's SortCommand event,
    it contains a member property called "SortExpression", this field just
    contains the
    "SortExpression" of the certain Column which is being sorted. We can set
    the "SortExpression" of each column in datagrid at design time.

    #DataGridColumn.SortExpression Property
    http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebUIWebContro
    lsDataGridColumnClassSortExpressionTopic.asp?frame=true

    And here are some related reference in MSDN on using the Datagrid's sort
    feature:

    #DataGrid.SortCommand Event
    http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontro
    lsdatagridclasssortcommandtopic.asp?frame=true

    #Adding Sorting to a DataGrid Web Server Control
    http://msdn.microsoft.com/library/en-us/vbcon/html/vbtskAddingSortingToDataG
    ridWebControl.asp?frame=true


    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
     
    Steven Cheng[MSFT], Jul 15, 2004
    #4
  5. Brian Henry

    Joe Fallon Guest

    You can inject a Label control after the Header text control of the Sort
    column.
    Use the Item Data Bound event for this.
    The label will just display " 5" or " 6". The space gives you a little
    separation fromthe header text.
    But the Font is Wingdings, x-small.
    (this gives you an up or down triangle.)

    I don't have any code samples handy but I use this trick and it works
    nicely.
    --
    Joe Fallon



    "Brian Henry" <> wrote in message
    news:...
    > is there a way to put a style or marker image on the header of a data grid
    > in asp.net to mark that this is the column being sorted on? thanks
    >
    >
     
    Joe Fallon, Jul 15, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amy Snyder

    Sort Dynamic Data Grid

    Amy Snyder, Dec 2, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    434
    Amy Snyder
    Dec 2, 2003
  2. thebison

    Data Grid Sort Problem

    thebison, Apr 10, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    565
    OHM \( One Handed Man \)
    Apr 10, 2006
  3. =?Utf-8?B?VmlkZHM=?=
    Replies:
    1
    Views:
    413
    =?Utf-8?B?SklHTkVTSA==?=
    Oct 9, 2007
  4. Ken Varn
    Replies:
    0
    Views:
    477
    Ken Varn
    Apr 26, 2004
  5. Navin
    Replies:
    1
    Views:
    706
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page