简单的 Asp.Net MVC2 绑定问题:如何获取 EditorFor 来渲染单选按钮组?
只是大声思考这个主题,如果我有以下内容:
<%= Html.EditorFor(m => m.Gender, "Gender")
并且我希望它呈现两个单选按钮:
O Male O Female
假设该类只有一个字符串来保存值,如果我们要传递 Gender.ascx 会是什么样子性别价值观使用类似
ViewData["Gender"] = new string[] {"Male", "Female"};
Just thinking out loud about the subject, If I have the following:
<%= Html.EditorFor(m => m.Gender, "Gender")
And I want it to render two radio buttons:
O Male O Female
Assuming the class just has a string to hold the value, what would the Gender.ascx look like if we were to pass the Gender values using something like
ViewData["Gender"] = new string[] {"Male", "Female"};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个单选按钮示例(是否):
另一个单选按钮集(性别):
和一个下拉菜单(婚姻状况):
现在我需要修改这些以查找匹配的 ViewData[""] 选项列表或弄清楚如何将选择列表传递到部分 UI 模板。
This is a Radio button example (Yes No):
And another Radio Button set (Gender):
And a Drop Down Menu (Marital Status):
Now I need to modify these to look for a matching ViewData[""] list of options or figure out how to pass a selection list to the partial UI Template.