title: Enum to View DropDown MVC3
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/388483/how-do-you-create-a-dropdownlist-from-an-enum-in-asp-net-mvc">How do you create a dropdownlist from an enum in ASP.NET MVC?</a>  </p>
  </blockquote>
  
  
  
  <p>I know there are several post that deal with dropdown in MVC3. I havent been able to find one that deal with my specific problem.</p>
  
  <p>I am trying to get all the options of my Enum into a dropdown in the View.</p>
  
  <p>Here is my Enum/Class:</p>
  
  <pre><code>namespace ColoringBook 
  public enum Colors
  {
      Red = 0,
      Blue = 1,
      Green = 2,
      Yellow = 3
  }
  
  public class Drawing
  {
      private Colors myColor;
  
      public Colors MyColor
      {
          get { return this.myColor; }
          set { this.myColor= value; }
      }
  
      public Drawing(Colors color)
      {
          this.myColor = color;
      }
  }
  </code></pre>
  
  <p>My view looks like this:</p>
  
  <pre><code>@model ColoringBook.Drawing
  
  
  @{
  Title = "Create";
  }
  
  &lt;h2&gt;Create&lt;/h2&gt;
  
  @using (Html.BeginForm()) 
  {
  @Html.ValidationSummary(true)
  &lt;fieldset&gt;
      &lt;legend&gt;Color&lt;/legend&gt;
  
  
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.Color)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          //not sure how to fill
          //@Html.DropDownList("Color",new SelectList())
  
      &lt;/div&gt;
   &lt;p&gt;
          &lt;input type="submit" value="Create" /&gt;
   &lt;/p&gt;
  &lt;/fieldset&gt;
  }
  </code></pre>
  
  <p>My controller would have the action result to give and receive data:</p>
  
  <pre><code>public class ColorController: Controller
  {
       public ActionResult Create()
       {
          return View();
       }
  
       [HttpPost]
       public ActionResult Create(Colors dropdownColor)
       {
          //do some work and redirect to another View
          return View(dropdownColor); 
       }
  </code></pre>
  
  <p>I am not worried about the Post(hence the lack of effort in reproducing the create code on receiving data from View), just the Get. Also the correct code for in the View from the dropdown.</p>
  
  <p>I have been advised not to use ViewBag. Other than that I am open to any good suggestions.</p>