簡體   English   中英

asp.net gridview如果單元格行值相等,則

[英]asp.net gridview if cell row value is equal then

我正在填充數據表,然后將其綁定到gridview。 現在,我正在讀取網格中的行,並在if value = [x]為行着色。

當我嘗試在頁面上顯示被復制的彩色行時,事情就發生了。 可以說我給第1行加了色,但是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"]);
}
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"]);
        }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM