title: ASP.NET MVC SelectList in ViewModel
body: <p>I'm working in ASP.NET MVC 5 (but this most likely applies to previous versions also).  Best way to ask this question is to show you the code:</p>
  
  <p>Here is the View Model:</p>
  
  <pre><code>public class PersonCreateViewModel
  {
      public SelectList cities {get; set;}
      public String Name { get; set; }
      public String Address { get; set; }
  
  }
  </code></pre>
  
  <p>Here is the http Post method from the controller:</p>
  
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public ActionResult Create(PersonCreateViewModel viewmodel)
  {
  
      if (ModelState.IsValid)
      {
          //Add to database here and return
  
      }
  
      //return back to view if invalid db save
      return View(person);
  }
  </code></pre>
  
  <p>Here is the View:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.person.name, new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
          @Html.EditorFor(model =&gt; model.person.name)
          @Html.ValidationMessageFor(model =&gt; model.person.name)
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.person.address, new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
          @Html.EditorFor(model =&gt; model.person.address)
          @Html.ValidationMessageFor(model =&gt; model.person.address)
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      @Html.LabelFor(model =&gt; model.person.CityID, "CityID", new { @class = "control-label col-md-2" })
      &lt;div class="col-md-10"&gt;
          @Html.DropDownList("cities")
          @Html.ValidationMessageFor(model =&gt; model.person.CityID)
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>When the user clicks submit, the following error message is in the browser:
  "No parameterless constructor defined for this object. "</p>
  
  <p>I think it has something to do with the fact that I have a SelectList in my ViewModel.  I think when the view passes the model back to the controller on form submission, it calls the constructor for the SelectList, but there is no parameterless constructor for SelectList.  I'm not sure how to proceed.  Any help is appreciated!!</p>