[英]Displays the results of data subtraction operations from the database only on the ASP.NET MVC page
我想顯示從數據庫中提取並僅在頁面視圖中顯示的數據的減法。 正如在源代碼中一樣,我想用使用的數量減去配額數量,這將等於剩余值。 剩余的值將顯示在頁面視圖上,而無需將結果保存在數據庫中。 我正在使用 ASP.NET MVC 和 MySQL 數據庫。 謝謝你。
@model IEnumerable<Train.Models.Ticket>
...
@foreach (var item in Model){
<tr>
<td>@Html.DisplayFor(modelItem => item.Quota)</td>
<td>@Html.DisplayFor(modelItem => item.Used)</td>
<!-- <td>Quota - Used = ?</td> -->
</tr>
}
你可以簡單地做
<td>@(item.Quota - item.Used)</td>
謝謝
你可以做
<td>Remaining value=item.Quota-item.Used</td>
<td>@(item.Quota - item.Used)</td>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.