我正在填充一个数据表,然后将其绑定到网格视图上。现在,我正在读取网格中的行,并且如果值等于[x],则将该行着色。
问题在于,当我尝试在页面上显示已经着色的行时,它会被重复显示。假设我已经着色了一行,但
问题在于,当我尝试在页面上显示已经着色的行时,它会被重复显示。假设我已经着色了一行,但
response.write
的结果会出现100次相同的内容。以下是我的代码,请希望有人能帮忙:protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
string alert = Request.QueryString["check"];
// loop over all the Rows in the Datagridview
foreach (GridViewRow row in gv1.Rows)
{
// if condition is met color the row text
if (gv1.Rows[0].Cells[0].Text.ToString() == alert)
{
Session ["fn"] = gv1.Rows[0].Cells[2].Text;
gv1.Rows[0].ForeColor = Color.Red;
}
Response.Write(Session["fn"]);
}