C# asp.net gridview如果单元格行值相等,则
我正在填充一个datatable,然后将其绑定到gridview。现在我正在读取网格中的行,并在value=[x]的情况下为行着色 当我试图在页面上显示有颜色的行时,我得到了它的副本。 假设我给1行上色,但是C# asp.net gridview如果单元格行值相等,则,c#,asp.net,gridview,C#,Asp.net,Gridview,我正在填充一个datatable,然后将其绑定到gridview。现在我正在读取网格中的行,并在value=[x]的情况下为行着色 当我试图在页面上显示有颜色的行时,我得到了它的副本。 假设我给1行上色,但是响应。write将是相同结果的100倍。 下面是我的代码,希望有人能帮忙: protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e) { string alert = Request.QueryStr
响应。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"]);
}
protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
string alert = Request.QueryString["check"];
if (e.Row.Cells[0].Text.ToString() == alert)
{
Session ["fn"] = e.Rows.Cells[2].Text;
e.Rows.ForeColor = Color.Red;
Response.Write(Session["fn"]);
}
}