title: System.InvalidOperationException: 'There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'Meal_Plan'.'2022
body: <p>I am trying to run an MVC app but it shows the following error:</p>
  <p>When it runs it shows table information from Faculty Table, but when I click on Add new, it shows the next error message:</p>
  <pre class="lang-none prettyprint-override"><code>System.InvalidOperationException: 'There is no ViewData item of type 'IEnumerable&lt;SelectListItem&gt;' that has the key 'Meal_Plan'.'
  
  
  System.InvalidOperationException
    HResult=0x80131509
    Message=There is no ViewData item of type 'IEnumerable&lt;SelectListItem&gt;' that has the key 'Meal_Plan'.
    Source=System.Web.Mvc
    StackTrace:
     at System.Web.Mvc.Html.SelectExtensions.GetSelectData(HtmlHelper htmlHelper, String name)
     at System.Web.Mvc.Html.SelectExtensions.SelectInternal(HtmlHelper htmlHelper, ModelMetadata metadata, String optionLabel, String name, IEnumerable`1 selectList, Boolean allowMultiple, IDictionary`2 htmlAttributes)
     at System.Web.Mvc.Html.SelectExtensions.DropDownList(HtmlHelper htmlHelper, String name, IEnumerable`1 selectList, Object htmlAttributes)
     at ASP._Page_Views_Faculty_Guardar_cshtml.Execute() in C:\Users\josem\Desktop\Code POS\POS\POS\Views\Faculty\Guardar.cshtml:line /at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
     at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
     at System.Web.WebPages.StartPage.ExecutePageHierarchy()
     at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
     at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
     at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
     at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>@model POS.Models.Faculty
  
  @{
      ViewBag.Title = &quot;Guardar&quot;;
  }
  
  &lt;h2&gt;Guardar&lt;/h2&gt;
  
  
  
  @using (Html.BeginForm(&quot;Nuevo&quot;,&quot;Producto&quot;,FormMethod.Post)) //Metodo &quot;Nuevo&quot;, Controlador &quot;Producto&quot;, Accion &quot;HTTP POST&quot;
  {
      @Html.AntiForgeryToken()
      
  &lt;div class=&quot;form-horizontal&quot;&gt;
      &lt;h4&gt;Faculty&lt;/h4&gt;
      &lt;hr /&gt;
      @Html.ValidationSummary(true, &quot;&quot;, new { @class = &quot;text-danger&quot; })
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Organization_Name, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Organization_Name, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Organization_Name, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.First_Name, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.First_Name, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.First_Name, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Last_Name, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Last_Name, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Last_Name, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Job_Title, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Job_Title, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Job_Title, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Email, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Email, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Email, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Photo, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Photo, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Photo, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Address, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Address, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Address, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Phone_Number, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.EditorFor(model =&gt; model.Phone_Number, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
              @Html.ValidationMessageFor(model =&gt; model.Phone_Number, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Meal_Plan, &quot;Meal_Plan&quot;, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              @Html.DropDownList(&quot;Meal_Plan&quot;, null, htmlAttributes: new { @class = &quot;form-control&quot; })
              @Html.ValidationMessageFor(model =&gt; model.Meal_Plan, &quot;&quot;, new { @class = &quot;text-danger&quot; })
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          @Html.LabelFor(model =&gt; model.Meal_Plan_Status, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
          &lt;div class=&quot;col-md-10&quot;&gt;
              &lt;div class=&quot;checkbox&quot;&gt;
                  @Html.EditorFor(model =&gt; model.Meal_Plan_Status)
                  @Html.ValidationMessageFor(model =&gt; model.Meal_Plan_Status, &quot;&quot;, new { @class = &quot;text-danger&quot; })
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          &lt;div class=&quot;col-md-offset-2 col-md-10&quot;&gt;
              &lt;input type=&quot;submit&quot; value=&quot;Guardar&quot; class=&quot;btn btn-default&quot; /&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;form-group&quot;&gt;
          &lt;div class=&quot;col-md-offset-2 col-md-10&quot;&gt;
              &lt;font color=&quot;green&quot;&gt;@ViewBag.mensaje&lt;/font&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  }
  
  &lt;div&gt;
      @Html.ActionLink(&quot;Back to List&quot;, &quot;Index&quot;)
  &lt;/div&gt;
  
  @section Scripts {
      @Scripts.Render(&quot;~/bundles/jqueryval&quot;)
  }
  </code></pre>