[英]Sum in a razor view with ASP.NET
我想要做的是兩個模型(剃須刀 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.Descuento
和Model.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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.