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;
}
}
}
}
这里即使条件满足,程序控制也不会进入并执行forecolor语句
答案 0 :(得分:1)
尝试(e.Row.Cells[i].Text).Trim()
,以防最后被忽视的空白区域。