如何将两列相乘并显示结果
How to multiply two columns and show the result
在我的应用程序中有一个 table 显示我从控制器传递的数据。
在最后一列中,我想通过将数量和单位数量数据相乘来显示总数量。
我可以得到帮助来做这个方法吗?提前致谢。
这是代码
<div class="row">
<div class="col-12 table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Requesting Item</th>
<th>Required Qty</th>
<th>Unit Amount</th>
<th>Total Amount</th>
</tr>
</thead>
<tbody>
@{int RowNo = 0;}
@for (int i = 0; i < Model.First().PurchaseOrderItems.Count; i++)
{
<tr>
<td>@{RowNo++;} @RowNo</td>
<td>@Html.DisplayFor(Model => Model.First().PurchaseOrderItems[i].Item_Description)</td>
<td>@Html.DisplayFor(Model => Model.First().PurchaseOrderItems[i].Qty)</td>
<td>Rs.@Html.DisplayFor(Model => Model.First().PurchaseOrderItems[i].UnitAmount)</td>
<td></td>
</tr>
}
</tbody>
</table>
</div>
</div>
我会在您的控制器中处理计算,然后将该计算的输出设置为您模型上的新 属性(如 TotalAmount
或 PurchasedOrderTotalAmount
)。这将使它更容易在您的模板中呈现。
<div class="row">
<div class="col-12 table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Requesting Item</th>
<th>Required Qty</th>
<th>Unit Amount</th>
<th>Total Amount</th>
</tr>
</thead>
<tbody>
@{int RowNo = 0;}
@for (int i = 0; i < Model.First().PurchaseOrderItems.Count; i++)
{
<tr>
<td>@{RowNo++;} @RowNo</td>
<td>@Html.DisplayFor(Model => Model.First().PurchaseOrderItems[i].Item_Description)</td>
<td>@Html.DisplayFor(Model => Model.First().PurchaseOrderItems[i].Qty)</td>
<td>Rs.@Html.DisplayFor(Model => Model.First().PurchaseOrderItems[i].UnitAmount)</td>
<td></td>
</tr>
}
<tr>
<td colspan="4">Total Amount:</td>
<td>Rs.@Html.DisplayFor(Model => Model.First().PurchasedOrderTotalAmount)</td>
</tr>
</tbody>
</table>
</div>
</div>
在我的应用程序中有一个 table 显示我从控制器传递的数据。
在最后一列中,我想通过将数量和单位数量数据相乘来显示总数量。
我可以得到帮助来做这个方法吗?提前致谢。
这是代码
<div class="row">
<div class="col-12 table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Requesting Item</th>
<th>Required Qty</th>
<th>Unit Amount</th>
<th>Total Amount</th>
</tr>
</thead>
<tbody>
@{int RowNo = 0;}
@for (int i = 0; i < Model.First().PurchaseOrderItems.Count; i++)
{
<tr>
<td>@{RowNo++;} @RowNo</td>
<td>@Html.DisplayFor(Model => Model.First().PurchaseOrderItems[i].Item_Description)</td>
<td>@Html.DisplayFor(Model => Model.First().PurchaseOrderItems[i].Qty)</td>
<td>Rs.@Html.DisplayFor(Model => Model.First().PurchaseOrderItems[i].UnitAmount)</td>
<td></td>
</tr>
}
</tbody>
</table>
</div>
</div>
我会在您的控制器中处理计算,然后将该计算的输出设置为您模型上的新 属性(如 TotalAmount
或 PurchasedOrderTotalAmount
)。这将使它更容易在您的模板中呈现。
<div class="row">
<div class="col-12 table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Requesting Item</th>
<th>Required Qty</th>
<th>Unit Amount</th>
<th>Total Amount</th>
</tr>
</thead>
<tbody>
@{int RowNo = 0;}
@for (int i = 0; i < Model.First().PurchaseOrderItems.Count; i++)
{
<tr>
<td>@{RowNo++;} @RowNo</td>
<td>@Html.DisplayFor(Model => Model.First().PurchaseOrderItems[i].Item_Description)</td>
<td>@Html.DisplayFor(Model => Model.First().PurchaseOrderItems[i].Qty)</td>
<td>Rs.@Html.DisplayFor(Model => Model.First().PurchaseOrderItems[i].UnitAmount)</td>
<td></td>
</tr>
}
<tr>
<td colspan="4">Total Amount:</td>
<td>Rs.@Html.DisplayFor(Model => Model.First().PurchasedOrderTotalAmount)</td>
</tr>
</tbody>
</table>
</div>
</div>