[英]change color of a cell in gridview
protected void gvSC_RowDataBound(object sender, GridViewRowEventArgs e)
{
string stext = TextBox1.Text.ToString();
stext = stext.Trim();
if (e.Row.RowType == DataControlRowType.DataRow)
{
int i;
for (i = 0; i < e.Row.Cells.Count; i++)
{
if ((e.Row.Cells[i].Text).ToString() == stext)
{
e.Row.Cells[i].ForeColor = System.Drawing.Color.Green;
}
}
}
}
here even though if condition satisfies, the program control is not going inside and executing forecolor statement 即使条件满足,程序控件也不会进入内部并执行前色语句
尝试使用(e.Row.Cells[i].Text).Trim()
,以防最后出现任何空白而被忽略。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.