title: ASP.NET Entity Framework - DropDownListFor Enum values
body: <p>I have a class like so:</p>
  
  <pre><code>namespace CentralParkVIPPreview.Models
  {
      [Table("CP-VIP-Preview")]
      public class CP_VIP_Preview
      {
          [Key]
          [DisplayName("Occupancy Timeline")]
          [Required]
          public string occupancyTimeline { get; set; }
      }
  
      public class Homefront : DbContext
      {
          public DbSet&lt;CP_VIP_Preview&gt; Data { get; set; }
      }
  
      public enum occupancyTimeline : int
      {
          TwelveMonths = 12,
          FourteenMonths = 14,
          SixteenMonths = 16,
          EighteenMonths = 18
      }
  
      public static class MyExtensions
      {
          public static SelectList ToSelectList(this occupancyTimeline enumObj)
          {
              var values = from occupancyTimeline e in Enum.GetValues(typeof(occupancyTimeline))
                           select new { Id = e, Name = string.Format("{0} Months", Convert.ToInt32(e)) };
              return new SelectList(values, "Id", "Name", enumObj);
          }
      }
  
  }
  </code></pre>
  
  <p>What I am trying to do is the following, take the values in the enum occupancyTimeline method (12, 14, 16, 18) and use them for a dropdown menu like so:</p>
  
  <pre><code>@model CentralParkVIPPreview.Models.CP_VIP_Preview
  @using CentralParkVIPPreview.Models
  
  @Html.DropDownListFor(model =&gt; model.occupancyTimeline, Model.occupancyTimeline.ToSelectList());
  </code></pre>
  
  <p>my problem is I am getting this error:</p>
  
  <pre><code>'string' does not contain a definition for 'ToSelectList' and the best extension method overload 'CentralParkVIPPreview.Models.MyExtensions.ToSelectList(CentralParkVIPPreview.Models.occupancyTimeline)' has some invalid arguments
  </code></pre>
  
  <p>on this line:</p>
  
  <pre><code>Model.occupancyTimeline.ToSelectList()
  </code></pre>
  
  <p>My question is, what am I doing wrong?</p>