title: how to use enum with DescriptionAttribute in asp.net mvc
body: <p>I am new to asp.net MVC. I am trying to use dropdown control on my view page, which populates from enum. I also want to add custom descriptions to dropdown values. I searched so many examples, but no one posted how to populated description on view page. Here is my code:</p>
  
  <p>ViewModel:</p>
  
  <pre><code>public enum SearchBy
      {
          [Description("SID/PID")]
          SID = 1,
          [Description("Name")]
          Name,
          [Description("Birth Date")]
          DOB,
          [Description("Cause#")]
          Cause
      }
  </code></pre>
  
  <p>Index.cshtml</p>
  
  <pre><code>&lt;div class="form-horizontal"&gt;
      @Html.ValidationSummary(true, "", new { @class = "text-danger" })
      &lt;div class="form-group form-inline"&gt;
          @Html.LabelFor(model =&gt; model.searchBy, htmlAttributes: new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.EnumDropDownListFor(model =&gt; model.searchBy, "Search By", htmlAttributes: new { @class = "form-control" })
              @Html.TextBox("searchByVal", null, htmlAttributes: new { @placeholder = "SID / PID ", @class = "form-control" })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.FirstName, htmlAttributes: new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.EditorFor(model =&gt; model.FirstName, new { htmlAttributes = new { @placeholder = "First Name", @class = "form-control" } })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.LastName, htmlAttributes: new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.EditorFor(model =&gt; model.LastName, new { htmlAttributes = new { @placeholder = "Last Name", @class = "form-control" } })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.DOB, htmlAttributes: new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.EditorFor(model =&gt; model.DOB, new { htmlAttributes = new { @placeholder = "Birth Date", @class = "form-control" } })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.CauseNumber, htmlAttributes: new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.EditorFor(model =&gt; model.CauseNumber, new { htmlAttributes = new { @placeholder = "Cause#", @class = "form-control" } })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;
          &lt;div class="col-md-offset-2 col-md-10"&gt;
              &lt;input type="submit" value="Search" class="btn btn-block btn-primary" /&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>It is not populating the with description fields as mentioned in my SearchBy enum. see the image here. 
  <a href="http://postimg.org/image/phdxgocj7/" rel="noreferrer">http://postimg.org/image/phdxgocj7/</a>
  Please help me, where I am making mistake. Thank you</p>
  
  <p><strong>UPDATE:</strong>
  I got solution for this from Nico. And I researched little bit on this. I am updating this post with solution because it may useful to others, who are new to MVC
  <a href="http://weblogs.asp.net/jongalloway//looking-at-asp-net-mvc-5-1-and-web-api-2-1-part-1-overview-and-enums" rel="noreferrer">http://weblogs.asp.net/jongalloway//looking-at-asp-net-mvc-5-1-and-web-api-2-1-part-1-overview-and-enums</a></p>
  
  <p>Thank you all. Enjoy coding..</p>