views:

54

answers:

1

Hi,

I have a GridView with image buttons for selecting rows. I am using an OnRowDataBound event to color selected rows Blue:

e.Row.ForeColor = System.Drawing.Color.Blue

Now that works great as long as I don't set a color either in the CSS stylesheet or on the grid Items themselves. If I do that, then all rows are colored that color and I don't get my Blue selected rows color for selected rows. I would like to color the text in the grid something other than black. Any ideas how to get around this?

Thank you, James

A: 

One way is just to have ASP.NET write the style to each cell in the row so that it overrides any CSS at the row level. Try...

foreach(TableCell cell in e.Row.Cells)
{
  cell.ForeColor = System.Drawing.Color.Blue;
}
George