There is no ViewData item of type 'IEnumerable' that has the key 'GradingId'

前端 未结 3 1405
庸人自扰
庸人自扰 2020-12-22 08:33

Im trying to get a drop-down list to work for users who are being graded. Each user can have multiple gradings. So when i create a new grade i want a drop-down to specify

3条回答
  •  無奈伤痛
    2020-12-22 09:31

    In Create get action you are not setting ViewBag.GradingId with the SelectList which is causing error in View:

    public ActionResult Create()
    {
            ViewBag.GradingId = new SelectList(db.Gradings, "GradingId", "CodeName");
            return View();
    }
    

提交回复
热议问题