绑定后加颜色,怎么弄???
绑定后加颜色,怎么弄???
现在绑定出来时这样的:李四34岁
新闻绑定出来是:苏有朋34岁
我想把minxinYanchu这个字段绑定出来变成红颜色,怎么绑定,其他的字段不变
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%#Page.ResolveUrl("~/ming/") + Eval("minxinID","../dengguang-xian.aspx?id={0}") %>' Text='<%#Eval("minxinTitle").ToString().Length>15?Eval("minxinTitle").ToString().Substring(0,10)+".":Eval("minxinTitle").ToString().Trim()+ Eval("minxinYanchu").ToString() %>'></asp:HyperLink>
[解决办法]
Text='<%#Eval("minxinTitle").ToString().Length>15?Eval("minxinTitle").ToString().Substring(0,10)+".":Eval("minxinTitle").ToString().Trim()+ "<font style='color:red'>" + Eval("minxinYanchu").ToString() + "</font>" %>'
试试
[解决办法]
后台databinging时间里去判断
[解决办法]
怎么会不行???
<%@ Page Language="C#" EnableViewState="true" AutoEventWireup="true" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> public System.Data.DataTable GetData() { System.Data.DataTable dataTable1 = new System.Data.DataTable("BlogUser"); dataTable1.Columns.Add(new System.Data.DataColumn("UserId", typeof(System.Int32))); dataTable1.Columns.Add(new System.Data.DataColumn("Title", typeof(System.String))); for (int i = 0; i < 8; i++) { dataTable1.Rows.Add(i, "测试" + i.ToString()); } return dataTable1; } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GridView1.DataSource = GetData(); GridView1.DataBind(); } }</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <asp:GridView ID="GridView1" runat="server" AutoGenerateEditButton="False"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%#Page.ResolveUrl("~/ming/") + Eval("UserId","../dengguang-xian.aspx?id={0}") %>' Text='<%#Eval("Title").ToString().Length>10?Eval("Title").ToString().Substring(0,10)+"...":Eval("Title").ToString().Trim()+ "<font style='color:red'>" + Eval("Title").ToString() + "</font>"%>'></asp:HyperLink> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </form></body></html>