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 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Gopaiah NekarukantiPosted Nov 1, 2019, 8:03 AM