文章内容

2017/10/7 15:56:59,作 者: 黄兵

@Html.RadioButtonFor 设置选中

在使用@Html.RadioButtonFor 的时候,如果从数据库读出一个数据,例如:

某人性别:男

如何在@Html.RadioButtonFor 输出的时候,“男”被选中呢?

代码如下:

@Html.RadioButtonFor(m => m.Gender, "Male", new { Checked = "checked" })

参考资料:How to Set RadioButtonFor() in ASp.net MVC 2 as Checked by default

分享到:

发表评论

评论列表