码迷,mamicode.com
首页 > Web开发 > 详细

MVC中使用RadioButtonFor

时间:2016-01-18 11:57:23      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:

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时,这第一条会显示被选中,反之,就是第二条显示选中。

MVC中使用RadioButtonFor

标签:

原文地址:http://www.cnblogs.com/zkwarrior/p/5138476.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!