ViewBag Issue - There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key RRS feed

  • Question

  • I don't know what happened but I believe this was working before. When I try to submit a form I have issues with the DropDownList I get the following error:

    'There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key ProjectName'

    Here is my controller:

    private void SetProjectViewBag(string ProjectName = null)

                if (ProjectName == null)

                    ViewBag.Project = new SelectList(_db.Projects, "ProjectName", "ProjectName");


                    ViewBag.Project = new SelectList(_db.Projects, "ProjectName", "ProjectName", ProjectName);


    public ActionResult AddProjectInventory()
                return View(new AddProjectInventory());

    Here is my html for the drop down list, and it works working on the form web page but I get that error when submitting the form. When I debug my ProjectName is there.

             <div class="editor-label">
            <div class="editor-field">
                @Html.DropDownList("ProjectName",ViewBag.Project as SelectList) 
                @Html.ValidationMessageFor(model => model.ProjectName)

    • Moved by Caillen Thursday, July 31, 2014 9:52 AM
    Wednesday, July 30, 2014 7:36 PM


  • Hi,

    ASP.NET MVC questions should be posted here:


    I suggest you firstly check the source HTML of the page to see if the generated HTML has something wrong.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Just Karl Friday, August 1, 2014 9:33 PM
    • Marked as answer by Just Karl Friday, August 8, 2014 4:38 PM
    Thursday, July 31, 2014 3:04 AM