在ASP.NET的剃刀视图中求和



我想做的是两个模型(razor ASP.NET)之间的和。(它们是在数据库中创建的)我不想在控制器中这样做,因为以后我希望它不修改我的值。我需要在视图中这样或那样做,取出forEach。非常感谢,我希望你的帮助。

<div class="cuartaParte">
<table style="width: 100%">
@foreach (var item in Model.PresupuestoDetalle){
<tr> //here I want to do the sum
<th scope="row" style="width: 70%; text-align: right">Descuento @Model.Cliente.Descuento+=@Model.DescuentoExtraPorcen%</th>
<td>$@Model.ImporteDescuento</td>
</tr>
}
</table>
</div>

如果您想在视图中显示两个模型之间的和,请尝试在Model.Cliente.DescuentoModel.DescuentoExtraPorcen%之外使用@();

<div class="cuartaParte">
<table style="width: 100%">
@foreach (var item in Model.PresupuestoDetalle){
<tr> //here I want to do the sum
<th scope="row" style="width: 70%; text-align: right">Descuento @(Model.Cliente.Descuento+@Model.DescuentoExtraPorcen%)</th>
<td>$@Model.ImporteDescuento</td>
</tr>
}
</table>
</div>

最新更新