Users Pricing

forum

Home Forums Dropdownlist from an enum in ASP.NET MVC – MindStick

Dropdownlist from an enum in ASP.NET MVC

Jayden Bell 2945 18 Nov 2014

I'm trying to use the Html.DropDownList extension method but can't figure out how to use it with an enumeration.

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? Or is my best bet to simply create a for loop and create the html elements manually?


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md