views:

577

answers:

2

Hi -

I have a block of code, that essentially is this:

<asp:DataGrid>
    <Columns>
        ...
        <asp:BoundColumn  HeaderText="Bar" ...>
            <itemstyle CssClass="foo">
        </asp:BoundColumn>

And this outputs

<table>
    <tr>
        <td>Bar</td>
        <td class="foo">...</td>
        <td class="foo">...</td>
        <td class="foo">...</td>
....

But I want this:

<table>
    <tr>
        <td class="foo">Bar</td>
        <td>...</td>
        <td>...</td>
        <td>...</td>
....

But I can't seem to achieve it. I'll bet this is simple but I'm having trouble finding it anywhere.

I tried this, but the output was the same:

<asp:DataGrid>
    <Columns>
        ...
        <asp:BoundColumn ItemStyle-CssClass="foo"  HeaderText="Bar" ...>
        </asp:BoundColumn>

Help appreciated!

A: 

You want HeaderStyle-CssClass instead of ItemStyle-CssClass.

<asp:BoundColumn HeaderStyle-CssClass="foo"  HeaderText="Bar" ...>
</asp:BoundColumn>
Matthew Jones
+1  A: 

Try Header Style:

<asp:BoundField DataField="bar" HeaderText="bar" SortExpression="bar">
   <ItemStyle    CssClass="fooItem"  />
   <HeaderStyle   CssClass="fooHeader"  />             
</asp:BoundField>

or if its applied to all headers

<Columns>
...
</Columns>
...
<HeaderStyle        CssClass="foo"  />
<RowStyle           CssClass="fooRow"    />
<AlternatingRowStyle CssClass="fooAltRow"    />
...
BigBlondeViking