相关疑难解决方法(0)

使用 AttributeDescription 字段的下拉列表枚举 ASP.NET MVC

基于这篇文章:How do you create a dropdownlist from an enum in ASP.NET MVC?

我想做完全相同的事情,除了使用枚举中的 AttributeDescription 字段,例如:

[DescriptionAttribute("1 Star")] OneStar = 1,
[DescriptionAttribute("2 Stars")] TwoStar = 2,
[DescriptionAttribute("3 Stars")] ThreeStar = 3,
[DescriptionAttribute("4 Stars")] FourStar = 4
Run Code Online (Sandbox Code Playgroud)

前面的链接中给出的解决方案将在下拉列表的文本字段中显示“OneStar”,而我希望看到“1 Star”。我看过一些与此相关的帖子,但他们的解决方案非常冗长。

asp.net-mvc-3

2
推荐指数
1
解决办法
3186
查看次数

标签 统计

asp.net-mvc-3 ×1