我需要做的是 - >綁定2 DropDownListFor在2個不同模型的視圖,我知道不能實現,因爲只有一個模型可以被調用在一個單一的觀點。如何填充2 DropDownListFor爲強類型模型
初始需求
@ Html.DropDownListFor(M => M.MobileList,新的SelectList(Model.MobileList, 「值」, 「文本」))
@ Html.DropDownListFor(M => M.CountryList,新的SelectList(Model.CountryList, 「價值」, 「文本」))
我做什麼
綁定下降的一個下使用
@ Html.DropDownListFor(M => M.MobileList,新的SelectList(Model.MobileList, 「價值」, 「文本」))
爲其他二手ViewBag。
@Html.DropDownList("Countrylist", (IEnumerable<SelectListItem>)ViewBag.Countrylist, new { id = "CountryId", @class = "form-control", @multiple = "multiple" })
但是我需要創建兩個使用@ Html.DropDownListFor剃刀碼下拉。
您是否考慮使用像這個Tuple這樣的「Tuple」作爲視圖的模型? –
User3250