title: The ViewData item that has the key 'XXX' is of type 'System.Int32' but must be of type 'IEnumerable<SelectListItem>'
body: <p>I have the following view model</p>
  
  <pre><code>public class ProjectVM
  {
      ....
      [Display(Name = "Category")]
      [Required(ErrorMessage = "Please select a category")]
      public int CategoryID { get; set; }
      public IEnumerable&lt;SelectListItem&gt; CategoryList { get; set; }
      ....
  }
  </code></pre>
  
  <p>and the following controller method to create a new Project and assign a <code>Category</code></p>
  
  <pre><code>public ActionResult Create()
  {
      ProjectVM model = new ProjectVM
      {
          CategoryList = new SelectList(db.Categories, "ID", "Name")
      }
      return View(model);
  }
  
  public ActionResult Create(ProjectVM model)
  {
      if (!ModelState.IsValid)
      {
          return View(model);
      }
      // Save and redirect
  }
  </code></pre>
  
  <p>and in the view</p>
  
  <pre><code>@model ProjectVM
  ....
  @using (Html.BeginForm())
  {
      ....
      @Html.LabelFor(m =&gt; m.CategoryID)
      @Html.DropDownListFor(m =&gt; m.CategoryID, Model.CategoryList, "-Please select-")
      @Html.ValidationMessageFor(m =&gt; m.CategoryID)
      ....
      &lt;input type="submit" value="Create" /&gt;
  }
  </code></pre>
  
  <p>The view displays correctly but when submitting the form, I get the following error message</p>
  
  <blockquote>
    <p>InvalidOperationException: The ViewData item that has the key 'CategoryID' is of type 'System.Int32' but must be of type 'IEnumerable&lt;SelectListItem&gt;'.</p>
  </blockquote>
  
  <p>The same error occurs using the <code>@Html.DropDownList()</code> method, and if I pass the SelectList using a <code>ViewBag</code> or <code>ViewData</code>.</p>