我有這個屬性使用Html.DropDownList的第5個重載會導致異常。 (不包含「DropDownList的」和最佳推廣方法重載的定義。)
public List<System.Web.Mvc.SelectListItem> ResponseTypes { get; set; }
在我看來,我有這個在我看來,這將導致錯誤的模型
錯誤CS1928:'System.Web.Mvc.HtmlHelper'不包含'DropDownList'的定義和最佳擴展方法重載'System.Web.Mvc.Html.SelectExtensions.DropDownList(System.Web.Mvc.HtmlHelper ,string
@Html.DropDownList("ResponseTypeId", "--Select Response Type--", question.ResponseTypes, new { @class = "form-control responseType", @id = "cbxType" })
我想使用此重載
public IHtmlString DropDownList(string name, string defaultOption, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes);
我似乎無法找出什麼不對的代碼。我相信我已經適當地跟蹤了過載。
我也試過鑄造它。我仍然無法工作。
@Html.DropDownList("ResponseTypeId", "--Select Response Type--", (IEnumerable<SelectListItem>)question.ResponseTypes, new { @class = "form-control responseType", @id = "cbxType" })
是不是過載....名稱,列表,默認條目?把默認條目前的選擇列表.....似乎對我的看法確定。 – Wheels73
你似乎是對的。但我不知道爲什麼intellisense告訴我默認值在我認爲的listItems –