title: Populating dropdown list with hardcoded values in .NET MVC 5
body: <p>I have a class like this:</p>
  
  <pre><code>public class MyClass
  {
       public SelectList saleRange = new SelectList(new[]
              {
                  new SelectListItem {  Selected = true ,Text = "--- Select date range ---", Value = "0" },
                  new SelectListItem { Selected = false, Text = "7 days", Value = "7" },
                  new SelectListItem  { Selected = false, Text = "14 days", Value = "14" },
                  new SelectListItem { Selected = false, Text = "21 days", Value = "21" },
                  new SelectListItem  { Selected = false, Text = "30 days", Value = "30" },
              }, "Value", "Text");
  
  }
  </code></pre>
  
  <p>My action:</p>
  
  <pre><code>   public ActionResult Index()
          { 
              var model = new MyClass();
              return View(model);
          }
  </code></pre>
  
  <p>And the view looks like this:</p>
  
  <pre><code>  @Html.DropDownListFor(m =&gt; m.saleRange, (IEnumerable&lt;SelectListItem&gt;)Model.saleRange,new { @class= "select2" , @style = "width:95%;border-left:2px solid #eee" })
  </code></pre>
  
  <p>But I'm getting this error:</p>
  
  <pre><code>Unable to cast object of type 'ServiceStack.Html.SelectList' to type 'System.Collections.Generic.IEnumerable`1[System.Web.Mvc.SelectListItem]'.
  </code></pre>
  
  <p>What am I doing wrong here? How can I populate the dropdownlist from my viewmodel with hardcoded values??</p>