title: Month and Year drop down list for ASP.NET mvc
body: <p>I'm trying to populate Month and Year in asp.net mvc project's cshtml view page</p>
  
  <p>this is the  view page code </p>
  
  <pre><code>@model IEnumerable&lt;project.Models.ProductStatistics&gt;
  
  @{
  
   }
  
  @Html.DropDownList("ExpirationMonth", ExpirationMonthDropdown)
  @Html.DropDownList("ExpirationYear", ExpirationYearDropdown)
  </code></pre>
  
  <p>this is the model</p>
  
  <pre><code>public class ProductStatistics
  {
  
      public IEnumerable&lt;SelectListItem&gt; ExpirationMonthDropdown
      {
          get
          {
              return Enumerable.Range(1, 12).Select(x =&gt;
  
                  new SelectListItem()
                  {
                      Text = CultureInfo.CurrentCulture.DateTimeFormat.AbbreviatedMonthNames[x - 1] + " (" + x + ")",
                      Value = x.ToString(),
                      Selected = (x == Model.ExpirationMonth)
                  });
          }
      }
  
      public IEnumerable&lt;SelectListItem&gt; ExpirationYearDropdown
      {
          get
          {
              return Enumerable.Range(DateTime.Today.Year, 20).Select(x =&gt;
  
              new SelectListItem()
              {
                  Text = x.ToString(),
                  Value = x.ToString(),
                  Selected = (x == Model.ExpirationYear)
              });
          }
      }
  
  }
  </code></pre>
  
  <p>but here I'm getting following error in Model Class</p>
  
  <blockquote>
    <p>The name 'Model' does not exist in the current context</p>
  </blockquote>
  
  <p>also getting this error in view page</p>
  
  <blockquote>
    <p>The name 'ExpirationMonthDropdown' does not exist in the current context</p>
  </blockquote>