gridview中的行按条件变色

来源:互联网 发布:网络代理飞机票 编辑:程序博客网 时间:2024/05/16 19:40
if (!IsPostBack)
        {
            databind();


            for (int i = 0; i < this.GridView1.Rows.Count - 1; i++)
            {
                Label Label1 = this.GridView1.Rows[i].FindControl("Label5") as Label; 
                string a = Label1.Text;  


                if (this.GridView1.Rows[i].Cells[2].Text == a)
                {
                    GridView1.Rows[i].BackColor = System.Drawing.Color.Red;
                }
            }
        }
0 0
原创粉丝点击