Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# asp.net gridview如果单元格行值相等,则_C#_Asp.net_Gridview - Fatal编程技术网

C# asp.net gridview如果单元格行值相等,则

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

我正在填充一个datatable,然后将其绑定到gridview。现在我正在读取网格中的行,并在value=[x]的情况下为行着色

当我试图在页面上显示有颜色的行时,我得到了它的副本。 假设我给1行上色,但是
响应。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"]);
        }
}