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
值。