models
ビューに2つ必要です。しかし、ビューを 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]'.
これは何ですか、どうすればこれを解決できますか?
アップデート
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);
}