我需要在我的视图中有2 models
。但由于我们只能添加1个视图,我采取了以下方法;尝试将多个模型添加到视图时出错提示
@model Tuple<My.Models.Mod1,My.Models.Mod2>
@Html.DropDownListFor(m => m.Item2.humanKind,Model.Item2.allHuman)
@Html.TextBoxFor(m => m.Item1.food)
但是,我最终得到的是以下错误;
The model item passed into the dictionary is of type 'My.Models.Mod2', but this dictionary requires a model item of type 'System.Tuple`2[My.Models.Mod1,My.Models.Mod2]'.
这是什么,我该如何解决这个问题?
UPDATE
public ActionResult Index()
{
var model2 = new Mod2 { allHuman = allHumans() };
var model1 = new Mod1(); // JUST NOW I ADDED THIS, BUT IT DOESn't WORK
return View(model1,model2);
}
发布您的控制器代码。 – 2013-02-18 21:54:29
您在这个'@model Tuple'代码行中的答案。 –
sigod
2013-02-18 21:56:21
对不起@EricJ。我误解了,你是对的。 – 2013-02-18 21:58:08