您的位置:首页 > 其它

GridView判断使文字显示不同的颜色的两种方法:1前右判断;2.后台判断

2009-09-15 14:00 501 查看
<asp:TemplateColumn HeaderText="油耗亏损">
<ItemTemplate>
<font color='<%# DataBinder.Eval(Container, "DataItem.overoil").ToString()[0]!='-'?"Red":"Green" %>'>
<asp:Label ID="Label6" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.overoil") %>'>
</asp:Label>
</font>
</ItemTemplate>
</asp:TemplateColumn>

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ("1".Equals(GridView1.DataKeys[e.Row.RowIndex].Values["OverDue"].ToString()))
{
e.Row.ForeColor = System.Drawing.Color.Red;
TextBox ZJCode = e.Row.FindControl("ZJCode") as TextBox;
DropDownList ddlCetificateType = e.Row.FindControl("ddlCertificateTypeNo") as DropDownList;
ddlCetificateType.ForeColor = System.Drawing.Color.Red;
ZJCode.ForeColor = System.Drawing.Color.Red;
TextBox StartDate = e.Row.FindControl("StartDate") as TextBox;
StartDate.ForeColor = System.Drawing.Color.Red;
TextBox EndDate = e.Row.FindControl("EndDate") as TextBox;
EndDate.ForeColor = System.Drawing.Color.Red;
TextBox Memo = e.Row.FindControl("Memo") as TextBox;
Memo.ForeColor = System.Drawing.Color.Red;
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: