【发布时间】:2010-02-23 03:38:49
【问题描述】:
我有一个显示来自数据库的数据的网格视图...目前我只能更改单元格中所有文本的颜色,但我需要做的只是更改某些文本的颜色。有没有办法做到这一点?这可能吗?我只是一个新手,所以请耐心等待我..
这是我更改单元格中文本颜色的功能:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (_SearchKey != string.Empty)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int ctr = 0; ctr < e.Row.Cells.Count; ctr++)
{
if (e.Row.Cells[ctr].Text.ToLower().Contains(_SearchKey.ToLower()))
{
e.Row.Cells[ctr].ForeColor = System.Drawing.Color.Red;
}
}
}
}
}
【问题讨论】:
标签: asp.net gridview text colors