我有这个属性使用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 –