DataGrid.AllowSorting and CssClass

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
You could always use a child selector in your CSS rules, along the lines of
..yourHeaderStyle a { text-decoration: blink; }
 
Back
Top