【发布时间】:2015-03-15 02:49:30
【问题描述】:
基于this 问题,我实现了一个 RadioButtonFor 编辑器模板。我工作得很好,但目前你不能传递你想要选择的值。
EnumRadioButtonList.cshtml (Editor Template):
@model Enum
@foreach (var value in Enum.GetValues(Model.GetType()))
{
if ((int)value > 0)
{
@Html.RadioButtonFor(m => m, (int)value)
@Html.Label(value.ToString())
}
}
我从 View 中调用它:
@Html.EditorFor(m => m.QuestionResponse, "EnumRadioButtonList")
如何传递值 QuestionResponse (enum) 以便选择单选按钮?
【问题讨论】:
标签: c# asp.net-mvc radio-button asp.net-mvc-5 mvc-editor-templates