我想將檢查的行的錶行值提交給我的控制器。我的控制器總是接收一個值爲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)
{
如果勾選框然後提交,它是否返回null? – jwatts1980 2014-09-22 20:30:34
是的,它的確如此。 。 。 – user1152145 2014-09-22 20:40:47
你可以發佈'@ Html.CheckBoxFor(c => row.isSelected)'生成的HTML代碼片段嗎? – jwatts1980 2014-09-22 20:42:03