这是我的看法:
@model Affiliate
<div class="box paint color_16">
<div class="title">
<h4><i class="icon-tasks"></i><span>@Model.CompanyName's Commissions</span> </h4>
</div>
<div class="content top ">
<div class="subtitle">
@Html.ActionLink("Void", "DeleteInvoice", new { commList = "??", affId = Model.Id }, new { @class = "btn" })
@Html.ActionLink("Create Invoice", "CreateInvoice", new { commList = "??", affId = Model.Id }, new { @class = "btn" })
@Html.ActionLink("Pay", "PayInvoice", new { commList = "??", affId = Model.Id }, new { @class = "btn" })
</div>
<table class="table table-striped table-hover">
<tr>
<h3>Commissions</h3>
</tr>
<tr>
<td></td>
<td>Amount</td>
<td>Status</td>
<td>Action</td>
</tr>
@foreach (var item in Model.Commissions)
{
<tr>
@if (item.Status == ViewBag.PaymentStatus || ViewBag.PaymentStatus == "All")
{
<td>@Html.CheckBox("commId", new { value = item.Id })</td>
<td>@Html.DisplayFor(x => item.PayoutAmount)</td>
<td>@Html.DisplayFor(x => item.Status)</td>
}
</tr>
}
</table>
</div>
我想要做的是当我点击顶部的操作链接时,从表中获取所有已检查的项目,并将该 id 列表传递给控制器逻辑。我假设视图模型可能是解决方案,如下所示:
public Affiliate affilite { get; set; }
public List<int> selectedItems { get; set; }
etc.
但是如何将选定的项目放入该 VM selectedItems 容器中?