1
I need my TD background to change according to the value it gets from Listview coming from a query.
<script type="text/javascript" >
$(function () {
var texto = $("#ListaSchedulesRdc td:nth-child(4)").text();
var resultado = (texto);
//alert(resultado);
for (resultado in "#ListaSchedulesRdc") {
if (resultado > 1) {
$("#ListaSchedulesRdc td:nth-child(4)").css("background-image", "url(../Imagens/alerta-vermelho.png)", "background-repeat: no-repeat;", "class='alerta-vermelho'");
}
if (resultado = 1) {
$("#ListaSchedulesRdc td:nth-child(4)").css("background-image", "url(../Imagens/alerta-amarelo.png)", "background-repeat: no-repeat;", "class='alerta-amarelo'");
}
if (resultado = 0) {
$("#ListaSchedulesRdc td:nth-child(4)").css("background-image", "url(../Imagens/alerta-verde.png)", "background-repeat: no-repeat;", "class='alerta-verde'");
}
}
});
<asp:ListView ID="ListaSchedulesRdc" runat="server" GroupPlaceholderID="groupPlaceHolder1" ItemPlaceholderID="itemPlaceHolder1" >
<LayoutTemplate>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table border ="1" ID="ListaSchedulesRdc">
<tr id="ListaSchedulesRdcTr">
<th>Nome </th>
<th>Ultima Rodada </th>
<th>Proxima Rodada </th>
<th>Ultimo Resultado </th>
<th>Quantidade Erros </th>
<th>Estado </th>
</tr>
<asp:PlaceHolder runat="server" ID="groupPlaceHolder1"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder1"></asp:PlaceHolder>
</tr>
</GroupTemplate>
<ItemTemplate>
<td><%# Eval("NomeTask") %> </td>
<td><%# Eval("UltimaRodadaTask") %> </td>
<td><%# Eval("ProximaRodadtaTask") %> </td>
<td id="ListaSchedulesRdcTd"><%# Eval("ResultadoTask") %> </td>
<td><%# Eval("ErrosTask") %> </td>
<td><%# Eval("EstadoTask") %> </td>
</ItemTemplate>
</asp:ListView>
In the status column?
– Leandro Angelo
Leandro, in the column Last Result, as well as in my image that is yellow, but should be in agreement with the If’s Javascript;
– Raphael Palladino
ah, you want to do by js, could put directly in your Itemtemplate and already render with the expected result, put together your question the html of the rendered table too, only the image does not help either.
– Leandro Angelo