Binding an Enum to a DropDownList in MVC 4? [dupli

2019-01-31 13:24发布

This question already has an answer here:

I've been finding all over the place that the common way to bind Enums to DropDowns is through helper methods, which seems a bit overbearing for such a seemingly simple task.

What is the best way to bind Enums to DropDownLists in ASP.Net MVC 4?

7条回答
Bombasti
2楼-- · 2019-01-31 13:46

I think it is about the only (clean) way, which is a pity, but at least there are a few options out there. I'd recommend having a look at this blog: http://paulthecyclist.com/2013/05/24/enum-dropdown/

Sorry, it's too long to copy here, but the gist is that he created a new HTML helper method for this.

All the source code is available on GitHub.

查看更多
登录 后发表回答