如何从ASP.NET MVC中的枚举创建下拉列表?
问题: I'm trying to use the Html.DropDownList extension method but can't figure out how to use it with an enumeration. 我正在尝试使用 Html.DropDownList 扩展方法,但无法弄清楚如何在枚举中使用它。 Let's say I have an enumeration like this: 假设我有一个这样的枚举: public enum ItemTypes { Movie = 1, Game = 2, Book = 3 } How do I go about creating a dropdown with these values using the Html.DropDownList extension method? 如何使用 Html.DropDownList 扩展方法使用这些值创建下拉列表? Or is my best bet to simply create a for loop and create the Html elements manually? 还是我最好的选择就是简单地创建一个for循环并手动创建HTML元素? 解决方案: 参考一: https://stackoom.com/question/1d3r/如何从ASP-NET