小弟将一个DATATABLE处理了,在DATATABLE中加了一列,当前一列的值小于某个值时,就在新加的一列的同一行上加入一个值为“正常”,当大于某个值时,就加上“不正常”,现在我的问题是,我要将“不正常”这个值显示为红色,请问怎么做呢?
解决方案 »
- 技术探讨:关于标签替换模板技术
- asp.net 关于数据库的开与关.
- 瀏覽器如何如何實現跳轉
- 2003经常连接不上服务器
- 发布网站时候于遇到的问题
- 获取图片的地址代码如何写?
- gridview在编辑状态下的显示控制问题
- 关于页面统一风格的问题!!!!
- 我的一个带有datagrid的页面,点击某行转到了另一页,比如做修改操作,然后我怎么回来?还回到datagrid的某一页呢?
- 最近用Nuget工具,总是提示不能被解析www.nuget.org,我ping也不通.设置里是https://www.nuget.org/api/v2/
- 用ConfigurationSettings的时候为啥总提示错误???
- 水晶报表的简单问题
这样写不行吗
创建一个模板列,
<asp:TemplateColumn>
<ItemTemplate>
<font color = '<%# databinder.evalcontainer.dataitem,"color")%>'>
<asp:label id="Label1" runat="server">
<%# databinder.eval(container.dataitem,"yourColumn") %>
</asp:Label></font> </ItemTemplate>
</asp:TemplateColumn>这样,yourcoloumn就可以按你自已定的颜色显示了。
<ItemTemplate>
<asp:Label runat="server" ForeColor='<%# GetColor(DataBinder.Eval(Container, "DataItem.sex").ToString()) %>' Text='<%# GetValue(DataBinder.Eval(Container, "DataItem.sex").ToString()) %>' ID="Label1">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
cs中
protected Color GetColor(string sex)
{
Color temp;
if(sex=="0")
temp=Color.Red;
else if(sex=="1")
temp=Color.Blue;
else
temp=Color.Black;
return temp;
}
</asp:Label>
请问,为什么我在模版列中放LABEL,为什么我的VS。NET中没有TEXT属性呢?为什么呢?
<ItemTemplate>
<asp:Label runat="server" ForeColor='<%# GetColor(DataBinder.Eval(Container, "DataItem.sex").ToString()) %>' Text='<%# GetValue(DataBinder.Eval(Container, "DataItem.sex").ToString()) %>' ID="Label1">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
cs中
protected Color GetColor(string sex)
{
Color temp;
if(sex=="0")
temp=Color.Red;
else if(sex=="1")
temp=Color.Blue;
else
temp=Color.Black;
return temp;
}