title: Bind Enum with dropdown and set selected value on get action in MVC C#
body: <p>I have a <code>Enum</code> called <code>CityType</code></p>
  
  <pre><code>public enum CityType
      {
          [Description("Select City")]
          Select = 0,
  
          [Description("A")]
          NewDelhi = 1,
  
          [Description("B")]
          Mumbai = 2,
  
          [Description("C")]
          Bangalore = 3,
  
          [Description("D")]
          Buxar = 4,
  
          [Description("E")]
          Jabalpur = 5
      }
  </code></pre>
  
  <p>Generate List from Enum</p>
  
  <pre><code>IList&lt;SelectListItem&gt; list = Enum.GetValues(typeof(CityType)).Cast&lt;CityType&gt;().Select(x =&gt;    new SelectListItem(){ 
      Text = EnumHelper.GetDescription(x), 
      Value = ((int)x).ToString()
  }).ToList(); 
  
  int city=0; 
  if (userModel.HomeCity != null) city= (int)userModel.HomeCity;
  ViewData["HomeCity"] = new SelectList(list, "Value", "Text", city);
  </code></pre>
  
  <p>Bind on .cshtml</p>
  
  <pre><code>@Html.DropDownList("HomeCity",null,new { @style = "width:155px;", @class = "form-control" })
  </code></pre>
  
  <p><strong><a href="https://stackoverflow.com/questions/4367723/get-enum-from-description-attribute">EnumHelper</a> GetDescription Class to get Description of Enum</strong></p>