21
可能重复:
CheckboxList in MVC3 View and get the checked items passed to the controller.的CheckBoxList在MVC3
你如何创建一个MVC3和CheckBoxList的返回是在提交检查结果。
Asp.net MVC3
可能重复:
CheckboxList in MVC3 View and get the checked items passed to the controller.的CheckBoxList在MVC3
你如何创建一个MVC3和CheckBoxList的返回是在提交检查结果。
Asp.net MVC3
有没有内置的框架,为你做这个帮手。但这并不困难。假设你已经在ViewBag中有一个选择列表,这将工作得很好。
@foreach (var o in ViewBag.Options) {
<label><input type="checkbox"
name="MyOptions"
value="@o.Value"/>
<span>@o.Text</span></label>
<br/>
}
您查看模型将需要能够接受一个数组,像这样...
public class MyViewModel {
public ICollection<string> MyOptions { get; set; }
}
选择将在MyOptions
值。