[HttpGet] public ActionResult _GetEmployeeSpeciality(string id) { DataTable dtdepartment = new DataTable(); FPDiabeticService.BoDataTable BODT = new FPDiabeticService.BoDataTable(); BODT = new Models.Frontdesk().FetchAllDepartmentList(); dtdepartment = BODT.PassTable; List<SelectListItem> ddldepartmentlist = new List<SelectListItem>(); ddldepartmentlist.Add(new SelectListItem { Text = "---Select a Department---", Value = "-1", Selected = true }); if (dtdepartment.Rows.Count > 0) { for (int i = 0; i < dtdepartment.Rows.Count; i++) { ddldepartmentlist.Add(new SelectListItem { Text = dtdepartment.Rows[i]["department"].ToString(), Value = dtdepartment.Rows[i]["departmentID"].ToString() }); } } ViewData["ddldepartmentlist"] = ddldepartmentlist; return View("_GetEmployeeSpeciality"); }
@Html.DropDownList("ddldepartmentlist")
@Html.DropDownList("ddldepartmentlist",ViewData["ddldepartmentlist"])
There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'ddldepartmentlist'
@Html.DropDownList("ddldepartmentlist",ViewData["ddldepartmentlist"] as IEnumerable<SelectListItem>)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)