如何使用 MVC 将 2 个单选按钮绑定到单个模型属性@Html.RadioButtonFor()
问问题
2266 次
1 回答
0
In your model:
public class MyModel
{
public bool? DoYouAgree { get; set; }
}
In your view:
<label>
@Html.RadioButtonFor(m => m.DoYouAgree, false,
new { id = "DoYouAgree_false" })
No
</label>
<label>
@Html.RadioButtonFor(m => m.DoYouAgree, true,
new { id = "DoYouAgree_true" })
Yes
</label>
于 2012-06-04T16:20:45.977 回答