解决方法
Elijah Manor写了ASP.NET MVC 1.0中相同的麻烦:
ASP.NET MVC Html.RadioButtonList Blues
他决定循环他的DataSource并创建单独的Html.RadioButton和Label组合。
<!-- After using and looking at the code for the Html.RadioButtonList in the ASP.NET MVC 1.0 RTM codebase,I'm not sure how it is supposed to be useful. It only outputs the actual input radio button and doesn't render any corresponding labels. To get around this I ended up writing a foreach creating individual Html.RadioButton and labels --> <% var radioButtonList = new SelectList(new List<ListItem> { new ListItem { Text = "Current",Value="false",Selected=true },new ListItem { Text = "Other",Value="true"}},"Value","Text","false"); var htmlAttributes = new Dictionary<string,object> { { "class","radioButtonList" },{ "onclick","if(eval(this.value)) { $('#tblDate').show('slow'); } else { $('#tblDate').hide('slow'); }" } }; foreach (var radiobutton in radioButtonList) { %> <%=Html.RadioButton("rblDate",radiobutton.Value,radiobutton.Selected,htmlAttributes)%> <label><%=radiobutton.Text%></label> <% } %>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。