问题描述
箭头颜色在数据库字段中给出 - OverallStatusCd和箭头背景色在数据库现场OverallTrendCd给出。
CSS是箭头和研究背景颜色写的。
我们可以通过改变'了使用下面的code访问这些东西,下,右,左和颜色是通过改变改变了绿色,红色
Arrow colour is given in the database field - "OverallStatusCd" and arrow background colour is given in database field- "OverallTrendCd".Css is written for arrows and backgroud colour.We can access these things using the code below by changing 'up','down', 'right','left' and colour is changed by changing 'green', 'red'
跨度ID =sptrend=服务器级=箭头向上箭头图标arrowgreen> / SPAN
span id="sptrend" runat="server" class="arrow arrow-up-icon arrowgreen">/span
我如何使用这个动态的基础上,从数据库中的信息?
OverallTrendCd所赐R代表红色,'Y'黄色
OverallStatusCd能值上,下,等等...
How can I use this dynamically based on the information from database?"OverallTrendCd" is giving 'R' for RED, 'Y' for YELLOW"OverallStatusCd" is giving values 'Up','Down', etc...
请你帮我#
推荐答案
尝试:
<span id="sptrend" runat="server" class='<%# String.Format(("{0}{1}"), Eval("OverallStatusCdClass"), Eval("OverallTrendCdClass "))%>'></span>
如果你必须inclue箭头
或比,是很难codeD,然后你可以改变字符串数据库以外的任何其他字符串.Format(({0} {1})
是的String.Format((箭头{0} {1})
if you must inclue 'arrow
' or any other string other than in the DB that is hard coded then you can alter String.Format(("{0}{1}"),
to be String.Format(("arrow {0}{1}")
注:我假设你的跨度在数据绑定控件。
Note: I assume that your span is in a databound control..
SELECT OverallStatusCd, OverallTrendCd,
CASE WHEN OverallStatusCd = 'Up' THEN 'up'
WHEN OverallStatusCd = '.Down' THEN 'down'
END AS OverallStatusCdClass ,
CASE WHEN OverallTrendCd = 'R' THEN 'red'
WHEN OverallTrendCd = 'Y' THEN 'yellow'
END AS OverallTrendCdClass
FROM YourTable
有关的SqlDataSource它会像在aspx页面(帮您联系延长我的答案在你心中的东西):
For SqlDataSource it will be something like in an aspx page (to help you relate things in your mind extending my answer) :
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<span id="sptrend" runat="server" class='<%# String.Format(("{0}{1}"), Eval("OverallStatusCdClass"), Eval("OverallTrendCdClass "))%>'></span>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="SELECT OverallStatusCd, OverallTrendCd,
CASE WHEN OverallStatusCd = 'Up' THEN 'up'
WHEN OverallStatusCd = '.Down' THEN 'down'
END AS OverallStatusCdClass ,
CASE WHEN OverallTrendCd = 'R' THEN 'red'
WHEN OverallTrendCd = 'Y' THEN 'yellow'
END AS OverallTrendCdClass
FROM YourTable">
</asp:SqlDataSource>
这篇关于我怎样才能把我的箭头方向箭头在asp.net颜色coolgrid基于从数据库中的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!