【发布时间】:2016-01-23 21:53:08
【问题描述】:
我试图通过一个下拉列表来查看视图,该列表由两个列表组成。一个用户拥有的 jobCode 列表和所有可用 jobCodes 的列表。我正在尝试将第三个列表传递到视图中,该列表是用户通过下拉列表拥有的所有作业代码,但我一直遇到这个问题......
The model item passed into the dictionary is of type
'System.Collections.Generic.List`1[System.String]',
but this dictionary requires a model item of type
System.Collections.Generic.IEnumerable`1[UserJobs]'.
public ActionResult addJob(string useCode)
{
var jobs = jobsClient.GetAlljobs();
var alljobsCode = (from s in jobs select s.jobCode).ToList();
var thisUserJobCode = (from s in db.UserJobs
where s.useCode == useCode
select s.jobCode).ToList();
var notObtained = alljobsCode.Except(thisUserJobCode);
ViewBag.jobCode = new SelectList(notObtained, "jobCode", "jobDescription");
return View(notObtained.ToList());
}
【问题讨论】:
-
看起来很像这个问题 - stackoverflow.com/q/34966533/745969 - 但不是完全重复的。听起来像是家庭作业……
标签: c# asp.net asp.net-mvc wcf asp.net-mvc-4