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

论坛 期权论坛 脚本     
匿名技术用户   2021-1-3 14:40   31   0

<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;
}
}
}

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP