title: How to create a dropdownlist from an enum in ASP.NET MVC?
body: <p>I'm trying to use the Html.DropDownList extension method but can't figure out how to use it with an enumeration.</p>
  
  <p>My classes : </p>
  
  <pre><code>namespace Support_A_Tree.Models
  {
      public enum Countries
      {
          Belgium,
          Netherlands,
          France,
          United_Kingdom,
          Other
      }
  
  
      [MetadataType(typeof(SupporterMetaData))]
      public partial class Person
      {
          public string Name { get; set; }
          public Countries Country { get; set; }
  
          public List&lt;SelectListItem&gt; allCountries()
          {
              List&lt;SelectListItem&gt; choices = new List&lt;SelectListItem&gt;();
              foreach (String c in Enum.GetValues(typeof(Countries)))
              {
                  choices.Add(new SelectListItem() { Text = c , Value = bool.TrueString });
              }
              return choices;
          }
  
  
      }
  
      public class SupporterMetaData
      {
          public string Name { get; set; }
  
          [Required]
          public Countries Country { get; set; }
      }
  }
  </code></pre>
  
  <p>In my VIEW I tried to get all countries, but it seems like i'm doing it wrong.</p>
  
  <pre><code>@using (Html.BeginForm())
  {
      &lt;div&gt;
          &lt;p style = "color: red;"&gt;@ViewBag.Message&lt;/p&gt;
      &lt;/div&gt;
  
      &lt;div&gt;
          &lt;h2&gt; You want to ... &lt;/h2&gt;
          &lt;p&gt;Plant trees&lt;/p&gt;
          @Html.CheckBoxSimple("support", new { @value = "Plant trees" })
  
          &lt;p&gt;Support us financial&lt;/p&gt;
          @Html.CheckBoxSimple("support", new { @value = "Support financial" })
      &lt;/div&gt;
  
      &lt;input type="submit" value="Continue "&gt;
  }
  </code></pre>