title: DropDownList items null when posting to edit form
body: <p>So I have a page to edit employees.</p>
  
  <p>Here is my view model:</p>
  
  <pre><code>public class EmployeesViewModel
  {
      [HiddenInput(DisplayValue = false)]
      public int EmployeeId { get; set; }      
  
      [Required(ErrorMessage = "Position is required")]
      [DisplayName("Position")]
      public int EmployeeTypeId { get; set; }
  
      [Required(ErrorMessage = "Name is required")]
      [DisplayName("Name")]
      public string Name { get; set; }
  
  
      public IEnumerable&lt;EmployeeType&gt; EmployeeTypes { get; set; }
  }
  </code></pre>
  
  <p>Here is my controller:</p>
  
  <pre><code>public class EmployeesController : Controller
  {
      public ActionResult Edit(int id)
      {
          //get employee from id
          var employee = GetEmployee(id);
  
          if (employee != null)
          {
              var viewModel = new EmployeesViewModel
              {
                  EmployeeId = employee.EmployeeID,
                  EmployeeTypeId = employee.EmployeeTypeID,
                  Name = employee.Name,
  
                  EmployeeTypes = _adminRepository.GetAllEmployeeTypes(),                    
              };
  
              return View(viewModel);
          }
  
          //if no employee exists for this id, redirect to the Create page and display a friendly message
          TempData["message"] = "No employee exists with an ID of " + id + ", you can create a new employee here.";
          return RedirectToAction("Create");
      }
  
  
  
      [HttpPost]
      public ActionResult Edit(EmployeesViewModel viewModel)
      {
          //if editing an employee, fetch it; otherwise, create a new one
          Employee employee = GetEmployee(viewModel.EmployeeId);
          TryUpdateModel(employee);
  
          if (ModelState.IsValid)
          {              
              SaveEmployee(employee);
              TempData["message"] = "Employee has been saved.";
              return RedirectToAction("Details", new { id = employee.EmployeeID });
          }
          return View(viewModel);     // validation error, so redisplay same view
      }
  }
  </code></pre>
  
  <p>And my Edit view page:</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="/Admin.Master" Inherits="System.Web.Mvc.ViewPage&lt;EmployeesViewModel&gt;" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"&gt;
  
      &lt;h1&gt;Edit Employee&lt;/h1&gt;
  
      &lt;% Html.EnableClientValidation(); %&gt;
      &lt;% using (Html.BeginForm("Edit", "Employees", FormMethod.Post)) { %&gt;
  
          &lt;%: Html.HiddenFor(m =&gt; m.EmployeeId)%&gt;
  
          &lt;div class="editor-label"&gt;&lt;%: Html.LabelFor(m =&gt; m.EmployeeTypeId) %&gt;&lt;/div&gt;
          &lt;div class="editor-field"&gt;
              &lt;%= Html.DropDownListFor(m =&gt; m.EmployeeTypeId, new SelectList(Model.EmployeeTypes, "EmployeeTypeID", "Position", Model.EmployeeTypeId), "- Select an Employee Type -")%&gt;
              &lt;%: Html.ValidationMessageFor(m =&gt; m.EmployeeTypeId)%&gt;
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;&lt;%: Html.LabelFor(m =&gt; m.Name) %&gt;&lt;/div&gt;
          &lt;div class="editor-field"&gt;
              &lt;%: Html.TextBoxFor(m =&gt; m.Name)%&gt;
              &lt;%: Html.ValidationMessageFor(m =&gt; m.Name)%&gt;
          &lt;/div&gt;
  
          &lt;p&gt;
              &lt;input type="submit" value="Save" /&gt;
              &lt;%: Html.ActionLink("Cancel", "Index") %&gt;
          &lt;/p&gt;
  
      &lt;% } %&gt;
  
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>After submitting my form, it fails at <code>if (ModelState.IsValid)</code>. It tries to redisplay the view when <code>return View(viewModel);</code> is called, and I get this error message:</p>
  
  <p><strong>Value cannot be null.</strong></p>
  
  <p><strong>Parameter name: items</strong></p>
  
  <p><em>&lt;%= Html.DropDownListFor(m => m.EmployeeTypeId, new SelectList(Model.EmployeeTypes, "EmployeeTypeID", "Position", Model.EmployeeTypeId), "- Select an Employee Type -")%></em></p>
  
  <p>I'm not sure why this is happening. The dropdown is loaded correctly when I navigate to the page, but not when the view is redisplayed.</p>
  
  <p>Does anyone know what's going on here?</p>