如何更改gridview单元格内的文本颜色.. [英] How to change text color inside a gridview cell..

查看:99
本文介绍了如何更改gridview单元格内的文本颜色..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在网格视图单元格中更改文本颜色,我尝试了前色,但它正在更改整个单元格颜色..

How to change text color inside a grid view cell,I tried fore-color but it is changing the entire cell color..

推荐答案

试试这个



Try This

if (e.Row.RowType == DataControlRowType.DataRow)
{
   var status = (Label)e.Row.FindControl("lblStatus");
   if (status.Text == "1")
   {
      e.Row.Cells[2].Text = "IN";
      e.Row.Cells[2].BackColor = Color.Blue;
      e.Row.Cells[2].ForeColor = Color.White;
   }
}


嗨...

你能看到这个链接!。

http ://stackoverflow.com/questions/18670189/how-to-style-asp-net-gridview-cells-with-colour-based-on-cell-value [ ^ ]

谢谢你。
Hi...
Can u see this link!.
http://stackoverflow.com/questions/18670189/how-to-style-asp-net-gridview-cells-with-colour-based-on-cell-value[^]
Thank u.


你可以使用CSS轻松完成。检查gridview单元格的id(如果你想在单个单元格中进行更改,否则使用class而不是id)并在样式选项卡中添加一个css(如果使用内部css,则将其放在样式表中)



ex:

You can easily do this using CSS. Check the id of the gridview cell (if u want to make the change in single cell only else use class instead of id) and add a css in the style tab (if using internal css else placed it in your stylesheet)

ex:
//for single cell use id whatever u have applied on your grid

#grid-cell
{
 color:#666666;
}







//for all cells use class name whatever u have applied on your grid

.grid-cell
{
 color:#666666;
}


这篇关于如何更改gridview单元格内的文本颜色..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆