Reputation: 139
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!
Upvotes: 3
Views: 8656
Reputation: 3963
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" />
...
Upvotes: 2
Reputation: 26190
You want HeaderStyle-CssClass instead of ItemStyle-CssClass.
<asp:BoundColumn HeaderStyle-CssClass="foo" HeaderText="Bar" ...>
</asp:BoundColumn>
Upvotes: 5