在下面的视图中,我试图将选中的复选框值发送到控制器以保存在数据库中。
<div class="editor-label">
<%: Html.LabelFor(model => model.Addresses) %>
</div>
<div class="editor-field">
<% foreach (var item in Model.Addresses)
{ %>
<input type="checkbox"
id="<%: item.addressID %>"
name="addressOption"
value="<%: item.addressID%>"/>
<label for="optionId"><%: item.address%></label>
<br />
<% } %>
</div>
<br />
<div class="editor-label">
<%: Html.LabelFor(model => model.Mobile) %>
</div>
控制器:
AdvanceClient cli = new AdvanceClient();
if (ModelState.IsValid)
{
cli.Mobile = Request.Form["Mobile"];
foreach (var item in Request.Form["Addresses"])
{
//here i need to get the checked checkbox values
}
}
我坚持获取选中复选框的值