有一个将被用于远程验证功能,但不能让它工作检查列表包含字符串
[HttpPost]
public JsonResult doesUserNameExist(string Forename)
{
IEnumerable<SelectListItem> user = new List<SelectListItem>();
using (EIPInternalEntities ctx = new EIPInternalEntities())
{
user = new SelectList(ctx.Database
.SqlQuery<string>("EXEC dbo.uspGetLkUpJobTitle")
.ToList());
}
var userlist = user.ToList();
//return Json(user == null);
return Json(!userlist.Contains(Forename));
}
尝试不同的方法,但目前的(用的名字))被标记为A级误差
“参数1不能从 '字符串' 转换为 'System.Web.Mvc.SelectListItem'
,如果我尝试
var userlist = (SelectList)user;
//return Json(user == null);
return Json(!userlist.Contains(Forename));
然后!userList
。遭到举报,称
的SelectList不包含定义包含
你为什么首先使用'SelectList'?使用一个普通的'列表' –
SimpleVar
嗨,谢谢,你能扩展一下吗?我很新c'和mvc – JQuery