I am getting error "System.InvalidOperationException: 'There is no ViewData item of type 'IEnumerable' that has the key 'ddlweb'. "
public ActionResult GetWebVersions()
{
ViewBag.ddlwebversion = MS.GetWebVersion();
return View("Version");
}
public dynamic GetWebVersion()
{
using (LystenEntities db = new LystenEntities())
{
//var weblist = db.WebVersions.Where(x => x.Status == "Current").OrderBy(x => x.Id).ToList();
return new SelectList(db.WebVersions.OrderBy(x => x.Id).ToList(), "Id", "Version");
}
}
@*@Html.DropDownList("ddlwebversion", (SelectList)ViewBag.ddlwebversion, "--- Select ---", new { @class = "form-control " })*@
@Html.DropDownList("ddlwebversion", (IEnumerable)ViewBag.ddlwebversion, "----Select---", new { @class = "form-control " })
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Gopaiah NekarukantiRank #2,077 · 695 reputationPosted Nov 1, 2019, 4:03 AM EDT