您的位置:首页 > 其它

MVC中使用RadioButtonFor

2016-01-18 10:24 281 查看
http://shw3588.blog.163.com/blog/static/6507576201321395845538/

1 进行初始化

<%=Html.RadioButtonFor(model => model.TypeState, 0, new { @id = "radio2", @name = "rdolstState" })%>启用
<%=Html.RadioButtonFor(model => model.TypeState, 1, new { @id = "radio1", @name = "rdolstState",@checked=true })%>禁用

注意:htmlAbrritbutes属性的使用 “new{………………………… }”;

2 编辑时,绑定值,根据数据显示RadioButtonFor选中状态

<%=Html.RadioButtonFor(model => model.TypeState, 0, new { @id = "radio2", @name = "rdolstState" })%>启用
<%=Html.RadioButtonFor(model => model.TypeState, 1, new { @id = "radio1", @name = "rdolstState" })%>禁用

说明:当数据中“TypeState”是0时,这第一条会显示被选中,反之,就是第二条显示选中。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: