开发者

How to color item text in GridView for non-selected lines only?

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 开发者_Python百科like to color the text in the grid something other than black. Any ideas how to get around this?


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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜