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;
}
}
}
<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;
}
}
}
相关文章推荐
- Android编程实现控件不同状态文字显示不同颜色的方法
- GridView 的 RowDataBound事件,文字显示不同颜色
- 微信小程序 后台返回的状态是数值,前端展示文字和不同颜色的简便方法
- WinForm------GridControl中通过判断单元格文字显示不同字体颜色或背景色
- C#在RichTextBox中显示不同颜色文字的方法
- TextView显示不同颜色文字--工具类TextUtil
- iOS UILabel显示文字设置不同的颜色以及行间距
- destoon实现不同会员组公司名称显示不同的颜色的方法
- Swift之改变状态栏显示颜色的两种方法
- label 显示不同颜色 不同文字点击事件
- 【HTML】通过不同的分辨率调用不同的css,两种方法:css本身判断、js调用css
- iOS 在一个UILabel里显示不同的颜色,给文字加下划线
- C# richTextBox显示不同文字颜色
- android中TextView同一行显示不同颜色文字
- iOS 在一个UILabel里显示不同的颜色,给文字加下划线
- android判断当前应用程序处于前台还是后台的两种方法
- repeater、gridview 在绑定时判断判断显示不同的行样式或文本
- Android判断当前应用程序处于前台还是后台的两种方法
- Html+Css+Js_之table每隔3行显示不同的两种颜色
- 关于Listview显示不同条目的两种方法