我正在创建一个HTML表单,其中列出了一个组织中需要映射到另一个组织的订单项。我的想法是获取所选选项的ID,并通过Html.Action将其传递给操作。这是我到目前为止的代码;
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.newID)
</th>
<th>
@Html.DisplayNameFor(model => model.oldserviceid)
</th>
<th>
@Html.DisplayNameFor(model => model.description)
</th>
<th>
@Html.DisplayNameFor(model => model.Avg)
</th>
<th>
@Html.DisplayNameFor(model => model.Count)
</th>
<th>
@Html.DisplayNameFor(model => model.acquisitionid)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@* This is where I'm stuck *@
<form action=@Html.Action("Update", new { linemappingID = @item.LineMapID, newID = /*what goes here?*/ }) method="post" onsubmit="return updateForm()" id="@item.LineMapID">
<input list="serviceList" name="serviceList">
<datalist id="serviceList">
@foreach (var serv in ViewBag.serviceList)
{
@* Pass the ID value from here to the Html.Action *@
<option value="@serv.serviceid - @serv.servicedesc" id="@serv.serviceid">@serv.serviceid - @serv.servicedesc</option>
}
</datalist>
<input type="submit" value="update" />
</form>
</td>
<td>
@Html.DisplayFor(modelItem => item.oldserviceid)
</td>
<td>
@Html.DisplayFor(modelItem => item.description)
</td>
<td>
$@Html.DisplayFor(modelItem => item.Avg)
</td>
<td>
@Html.DisplayFor(modelItem => item.Count)
</td>
<td>
@Html.DisplayFor(modelItem => item.acquisitionid)
</td>
</tr>
}
</table>