VS2005中某列换颜色的总结

来源:互联网 发布:网络暴力的特点 编辑:程序博客网 时间:2024/05/04 12:59

VS2005中某列换颜色的总结
 前台对应第5列
 <asp:BoundField DataField="Md_Status1" HeaderText="状态">
 <ItemStyle CssClass="item" HorizontalAlign="Center" Width="80px"  />
 </asp:BoundField>

后台
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
          
            if(e.Row.Cells[4].Text=="未回复")//如果是模板列不能这么用
            {
                e.Row.Cells[4].ForeColor = System.Drawing.Color.Red;
            }
        }
        
    } 

2.模板列
  <asp:TemplateField HeaderText="aa">
      <ItemStyle/>
     <ItemTemplate>
      <%# pay(Eval("aa").ToString())%>
      </ItemTemplate>
 </asp:TemplateField>

后台调用
  public string pay(string str)
    {
        if (str == "1")
        {
            return "<font color='red'> bb</font>";
        }
        else
        {
            return "cc";
        }

    }

 

原创粉丝点击