title: MVC 4 DropDownListFor error - There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key
body: <p>I have a model:</p>
  
  <pre><code>public class Auction
  {
      public string Title { get; set; }
      public string category { get; set; }
  }
  </code></pre>
  
  <p>And a controller:</p>
  
  <pre><code>[HttpGet]
  public ActionResult UserForm()
  {
  
      var categoryList = new SelectList(new[] { "auto", "elec", "games", "Home" });
      ViewBag.categoryList = categoryList;
      return View();
  
  }
  </code></pre>
  
  <p>In the View I have these lines:</p>
  
  <pre><code>&lt;div class="editor-field"&gt;
      @Html.DropDownListFor(model =&gt;
          model.category,(SelectList)ViewBag.categoryList)
      @Html.ValidationMessageFor(model =&gt; model.category)
  
  &lt;/div&gt;
  </code></pre>
  
  <p>The error I get when I try to save the form is:</p>
  
  <blockquote>
    <p>There is no ViewData item of type 'IEnumerable' that
    has the key 'category'. Description: An unhandled exception occurred
    during the execution of the current web request. Please review the
    stack trace for more information about the error and where it
    originated in the code.</p>
    
    <p>Exception Details: System.InvalidOperationException: There is no
    ViewData item of type 'IEnumerable' that has the key
    'category'.</p>
  </blockquote>
  
  <p>I dont understand what is the problem, since I did (or tried to do) everything that is done in this guide:
  <a href="https://www.youtube.com/watch?v=7HM6kDBj0vE" rel="noreferrer">https://www.youtube.com/watch?v=7HM6kDBj0vE</a></p>
  
  <p>The video can also be found in this link (Chapter 6 - Automatically binding to data in the request):
  <a href="http://www.lynda.com/ASPNET-tutorials/ASPNET-MVC-4-Essential-Training/109762-2.html" rel="noreferrer">http://www.lynda.com/ASPNET-tutorials/ASPNET-MVC-4-Essential-Training/109762-2.html</a></p>