What am I doing wrong here?
What I am trying to do is populate a list of Function Value and function Name into a jSon result that I will then use on my main page with jQuery.
The error is:
Error 5 Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'System.Web.Mvc.SelectList'. An explicit conversion exists (are you missing a cast?)
public ActionResult FilterFunctionList(int departmentID = 0)
{
if (departmentID == 0)
{
return this.Json(string.Empty, JsonRequestBehavior.AllowGet);
}
IPACS_Departments ipacs_department = db.IPACS_Department.Find(departmentID);
SelectList ipacs_functions = ipacs_department.IPACS_Functions.Select(m => new SelectListItem
{
Value = SqlFunctions.StringConvert((double)m.functionID).Trim(),
Text = m.name
});
return this.Json(ipacs_functions, JsonRequestBehavior.AllowGet);
}
#endregion