【发布时间】:2016-12-20 06:34:53
【问题描述】:
在 razor 视图中,我正在使用这样的枚举值渲染组合框
@Html.DropDownListFor(m => m.CarType, new SelectList(Enum.GetValues(typeof(CarTypeEnum))),
"Select value", new { @class = "form-control" })
public enum CarTypeEnum
{
[StringValue("Car type one")]
CarTypeOne = 1,
[StringValue("Car type two")]
CarTypeTwo = 2,
}
如何使用 DropDownListFor 助手在组合框中呈现 StringValue,例如
Car type one 而不是 CarTypeOne
【问题讨论】:
-
也可以参考this question的答案
标签: c# .net asp.net-mvc enums