我有一个看起来像这样的视图模型
public class ViewModelRound2
{
public Bid Bid { get; set; }
public bool SelectedForRound2 { get; set; }
}
我有一个看起来像这样的 get 操作方法
public ActionResult Round2Manager(long id)
{
...
return View(round1Ring3Bids);
}
还有一个看起来像这样的 post 方法(尚未实现)
[HttpPost]
public ActionResult Round2Manager(IEnumerable<ViewModelRound2> viewModelRound2)
{
return View(viewModelRound2);
}
我的观点看起来像这样
@for (var x = 0; x < Model.Count(); x++)
{
ViewModelRound2 viewModelRound2 = Model.ElementAt(x);
Bid bid = viewModelRound2.Bid;
string userName = @bid.User.Invitation.Where(i => i.AuctionId == bid.Lot.Lot_Auction_ID).First().User.User_Username;
<tr>
<td>
@userName
</td>
<td>
@bid.Bid_Value
</td>
<td>
@Html.EditorFor(c => c.ElementAt(x).SelectedForRound2)
</td>
</tr>
}
</table>
<div class="buttonwrapper2">
@Ajax.ActionLink("Select", "Round2Manager", new { viewModelRound2 = Model }, new AjaxOptions() { HttpMethod = "POST"} )
</div>
此呈现的页面包含呈现表中每行的复选框,我希望能够将选中/未选中的值传递给 post 方法,以便它可以处理它们。问题是viewModelRound2
post方法的参数总是为null。到底是怎么回事?我怎样才能写这个,以便它做我想要的?