我想提交检查到控制器的行的表行值。我的控制器总是接收一个值为null的参数。
@model IEnumerable<GoogleMapsAPIWeb.Models.Schedule>
@using (Html.BeginForm("Route", "Home", FormMethod.Post))
{
<div>
<table id="schedulerTable">
<thead>
<tr>
<th scope="col"></th>
<th scope="col" >View</th>
<th scope="col">Site Id</th>
</tr>
</thead>
<tbody>
@foreach (var row in Model)
{
<tr>
<td>@Html.CheckBoxFor(c=>row.isSelected)</td>
<td class="smallerDataField">
<a>View</a>@*TODO add code to view*@
</td>
<td><div class="smallerDataField">@row.SiteId</div></td>
</tr>
}
</tbody>
</table>
<input id="btnFindRoute" type="submit" value="Plan Route" />
</div>
}
[HttpPost]
public ActionResult Route(IEnumerable<Schedule> Schedules)
{
答案 0 :(得分:1)
为此目的使用for
循环。更多info
for (int i = 0; i < Model.Count(); i++)
{
<tr>
<td>@Html.CheckBoxFor(c=> Model[i].isSelected)</td>
</tr>
...
}