title: Getting an error message, 'There is no ViewData item with the key 'Reason' of type 'IEnumerable<SelectListItem>' for the DropDownList in asp.net mvc
body: <p>I'm very new to the ASP.net framework, and will appreciate it if somebody could help me to figure out what I'm doing wrong here.</p>
  
  <p>I'm trying to create a dropdownlist for the table field, "Reason" from a SelectList using asp.net mvc 3.5 (C#).</p>
  
  <p>In my View code I used MVC HTML method Html.DropdownList:</p>
  
  <pre><code>&lt;%= Html.DropDownList("Reason", Model.Reason)%&gt;
  &lt;%= Html.ValidationMessage("Reason", "*")%&gt;
  </code></pre>
  
  <p>In the Model class I added the list of 'reasons' in the code:</p>
  
  <pre><code>namespace Appointments.Models
  {
      public class AppointmentFormViewModel
      {
          public Appointment Appointment { get; set; }
          public Dictionary&lt;string, string&gt; ReasonValues
          {
              get
              {
                  return new Dictionary&lt;string, string&gt;()
                  {
                      { string.Empty, string.Empty },
                      { "Add/Drop", "Add/Drop a Course" },
                      { "Academic Diff.", "Academic Difficulty" },
                      { "Academic Plan", "Academic Plan" },
                      { "Other", "Other: Fill out below" }
                  };
              }
          }
          public SelectList Reason { get; set; }
  
          public AppointmentFormViewModel(Appointment appointment)
          {
              Appointment = appointment;
              Reason = new SelectList(ReasonValues, "Key", "Value", appointment.Reason);
          }
  </code></pre>
  
  <p>In the Controller the code is:</p>
  
  <pre><code>public ActionResult Index()
  {
      ViewData["Reason"] = new SelectList("ReasonValues");
      return View();
  }
  </code></pre>
  
  <p>When I'm debugging the code I'm getting an error message, 'There is no ViewData item with the key 'Reason' of type 'IEnumerable'. </p>
  
  <p>Thank you!</p>