设置datalist指定行的背景色

时间:2022-01-11 13:23:06

前台:

<div class="table-responsive" >
<table class="table table-bordered table-condensed" >
<asp:Repeater ID="ElectricYellowPage" runat="server" EnableViewState="False">
<HeaderTemplate>
<thead>
<tr>
<th colspan="6">电子黄页各区域新增、取消及收入情况</th>
<th rowspan="2">当月新增完成情况</th>
</tr>
<tr>
<th>地区</th>
<th>当日新增</th>
<th>当日取消</th>
<th>当日在网数</th>
<th>当月预计可结算金额</th>
<th>ARPU</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr <%# GetColor( Eval("Area"))%>>
<td><%#Eval("[Area]") %></td>
<td style="text-align:right"><%#Eval("[DayNewCrease]") %></td>
<td style="text-align:right"><%#Eval("[Daycancel]") %></td>
<td style="text-align:right"><%#Eval("[DayInter]") %></td>
<td style="text-align:right"><%#Eval("[ARPU]") %></td>
<td style="text-align:right"><%#Eval("[ExpectedSettlement]") %></td>
<%-- <td rowspan="<%=rowscount %>"></td> --%>
<td id="tdnewCreat" runat="server" style="text-align:center;vertical-align:middle"><%#Eval("[NewCreatComplay]") %></td>
</tr>
</ItemTemplate>
<%-- <FooterTemplate>
<tr style="background-color:#FED966;" >
<td>合计</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</FooterTemplate> --%>
</asp:Repeater>
</table>
</div>

 

后台:

public string GetColor(object name) {
string ChannelName=Convert.ToString(name);

if (ChannelName == "合计" || ChannelName == "总计")
{
return "style='background-Color:#FED966;'";
}
else if (ChannelName == "短信" || ChannelName == "客户端" || ChannelName == "外呼" || ChannelName == "小计")
{
return "style='background-Color:#D0CECF;'";
}
else {
return "";
}

}