DataGrid.AllowSorting and CssClass

Discussion in 'ASP .Net' started by =?Utf-8?B?a2g=?=, Aug 2, 2004.

  1. Hi. If I set DataGrid.AllowSorting=True my column headers are automatically rendered as hyperlinks. How can I explicitly tell the DataGrid what CssClass to use for these hyperlinks?

    Note that this is not the same as this:
    <HeaderStyle CssClass=myClass1></HeaderStyle>

    I suppose I'm looking for something like:
    <HeaderStyle CssClass=myClass1 HyperlinkCssClass=myClass2></HeaderStyle>

    Thanks

    kh
     
    =?Utf-8?B?a2g=?=, Aug 2, 2004
    #1
    1. Advertising

  2. Played around a bit more and I can do this, but was hoping for a declarative method:

    private void myDatagrid_ItemCreated(object sender, DataGridItemEventArgs e)
    {
    if(e.Item.ItemType==ListItemType.Header)
    foreach(Control ctl in e.Item.Controls)
    foreach(Control ctl2 in ctl.Controls)
    if(ctl2.GetType().BaseType==typeof(LinkButton))
    ((LinkButton)ctl2).CssClass="clsSubHeading";
    }

    kh
     
    =?Utf-8?B?a2g=?=, Aug 2, 2004
    #2
    1. Advertising

  3. You could always use a child selector in your CSS rules, along the lines of
    ..yourHeaderStyle a { text-decoration: blink; }

    "kh" wrote:

    > Hi. If I set DataGrid.AllowSorting=True my column headers are automatically rendered as hyperlinks. How can I explicitly tell the DataGrid what CssClass to use for these hyperlinks?
    >
    > Note that this is not the same as this:
    > <HeaderStyle CssClass=myClass1></HeaderStyle>
    >
    > I suppose I'm looking for something like:
    > <HeaderStyle CssClass=myClass1 HyperlinkCssClass=myClass2></HeaderStyle>
    >
    > Thanks
    >
    > kh
    >
    >
     
    =?Utf-8?B?SmVyZW15IERhdmlz?=, Aug 2, 2004
    #3
  4. =?Utf-8?B?a2g=?=

    Joe Fallon Guest

    Thanks for posting.
    I had the same problem.
    --
    Joe Fallon


    "kh" <> wrote in message
    news:...
    > Played around a bit more and I can do this, but was hoping for a

    declarative method:
    >
    > private void myDatagrid_ItemCreated(object sender, DataGridItemEventArgs

    e)
    > {
    > if(e.Item.ItemType==ListItemType.Header)
    > foreach(Control ctl in e.Item.Controls)
    > foreach(Control ctl2 in ctl.Controls)
    > if(ctl2.GetType().BaseType==typeof(LinkButton))
    > ((LinkButton)ctl2).CssClass="clsSubHeading";
    > }
    >
    > kh
     
    Joe Fallon, Aug 3, 2004
    #4
    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. Cowboy \(Gregory A. Beamer\)

    Export datagrid(with allowsorting) to Excel

    Cowboy \(Gregory A. Beamer\), Jun 25, 2003, in forum: ASP .Net
    Replies:
    6
    Views:
    537
  2. Samuel Shulman

    AllowSorting dosn't work

    Samuel Shulman, Jun 13, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    3,693
    Samuel Shulman
    Jun 13, 2006
  3. Julia B
    Replies:
    0
    Views:
    789
    Julia B
    Nov 3, 2009
  4. tony010409020622@

    AllowSorting = True, BUT Web DataGrid Wont Sort

    tony010409020622@, Sep 29, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    198
    Scott M.
    Sep 29, 2005
  5. Dan Dorey via .NET 247

    dynamic datagrids and allowsorting

    Dan Dorey via .NET 247, Aug 4, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    122
    Dan Dorey via .NET 247
    Aug 4, 2004
Loading...

Share This Page