1

I've got an asp ASP:DataGrid, and within this 5 columns. Now i could use pure CSS such as :nth-child but for maximum comparability I'd love to just slot a class onto the 5th td in the row server-side so that i am not relying on Javascript to save me.

Can this be done? I know you can add a class to the table row via HeaderStyle-CssClass="foo"

Paritosh
  • 11,144
  • 5
  • 56
  • 74
Gerico
  • 5,079
  • 14
  • 44
  • 85
  • You shouldn't put asp.net mvc into your tags if your question is connected to asp.net – Andrei Sep 18 '13 at 13:19
  • possible duplicate of [How to set the style of a cell in asp:DataGrid?](http://stackoverflow.com/questions/10586854/how-to-set-the-style-of-a-cell-in-aspdatagrid) – Andrei Sep 18 '13 at 13:21
  • Not a duplicate question as i am using Datagrids, whereas i believe the answer accepts in the other question is for GridViews – Gerico Sep 18 '13 at 13:43

1 Answers1

1

I found a solution for anyone who this might help. Due to not being in control of the bulk of the code i couldn't implement a gridview so i had to work with the datagrid.

In order to apply a class to a td in the table, you can do the follow:

ItemStyle-CssClass="foo"

On the TemplateColumn, like so:

<asp:TemplateColumn ItemStyle-CssClass="foo" HeaderText="Header Text">
Gerico
  • 5,079
  • 14
  • 44
  • 85