我有一个表,当实际库存低于最低库存时,我想标记它,为此,我将使用Razor呈现视图,但我得不到结果
我附上我的视图,其中包含我们希望干预的表
<table class="table table-bordered table-hover table-condensed">
<tr>
<th>
@Html.DisplayNameFor(model => model.First().v_Nombre)
</th>
<th>
@Html.DisplayNameFor(model => model.First().StockReal)
</th>
<th>
@Html.DisplayNameFor(model => model.First().StockMinimo)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
var fila = string.Empty;
if(item.StockReal < item.StockMinimo)
{
fila = "danger";
}
<tr class="@fila">
<td>
@Html.DisplayFor(modelItem => item.v_Nombre)
</td>
<td>
@Html.DisplayFor(modelItem => item.StockReal)
</td>
<td>
@Html.DisplayFor(modelItem => item.StockMinimo)
</td>
<td>
<a href="#" class="btn btn-outline-warning" onclick="EditarProducto(@item.Kn_CodigoProducto)">Editar </a>
</td>
</tr>
}
</table>
预期行为:实际库存量低于最低库存量的行将变为红色
实现的行为:我的观点没有变化
我做错了什么?我的Razor代码中缺少什么?对我有什么帮助吗?
发布于 2018-06-05 05:01:30
在bootstrap 4中,class
为table-danger
,因此请更改代码:
if(item.StockReal < item.StockMinimo)
{
fila = "table-danger";
}
https://stackoverflow.com/questions/50688563
复制相似问题