[Solved] How can I give my arrow direction and arrow color in asp.net coolgrid based on information from database?


Try:

<span id="sptrend" runat="server" class="<%# String.Format(("{0}{1}"), Eval("OverallStatusCdClass"), Eval("OverallTrendCdClass "))%>"></span>

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

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>

7

solved How can I give my arrow direction and arrow color in asp.net coolgrid based on information from database?