比如这个字段的值是1,那么这一行就显示红色,字段的值是2,相应的行就显示黄色.用VB.NET实现

解决方案 »

  1.   

    将该字段设置为模板列,比如Label_f,在RowDataBound事件中: 
    Label Label_f= (Label)(e.Row.FindControl("Label_f"));
            if (Label_f!= null)
            {
                if(Label_f.text=="1")
                {
                   e.Row.BackColor = Color.Red;
                 }
            }
      

  2.   

    在绑定的时候写.
    gridview_OnDataBound(){
        Label label1 = e.Item.FindControl("lable1") as Label;
        Label label2 = e.Item.FindControl("lable2") as Label;
        if(lable1.Text == "1") {
           label2.ForeColor = "red";
        }else if(lable1.Text == "2"){
           label2.ForeColor = "blue";
         } 
    }大概是这样,给你个思路,可能语句写得不对。