微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 将Bootstrap类应用于@ Html.DropDownList()

我正在尝试将引导样式应用于以下下拉列表:
@Html.DropDownList("Scholarship_contactID","-- Select Contact --",new { @class = "form-control"})

这将返回以下错误

‘System.Web.Mvc.HtmlHelper’ does not contain a deFinition for ‘DropDownList’ and the best extension method overload ‘System.Web.Mvc.Html.SelectExtensions.DropDownList(System.Web.Mvc.HtmlHelper,string,System.Collections.Generic.IEnumerable,string)’ has some invalid arguments

解决方法

您没有为下拉列表中的项目提供任何内容.

注意这部分错误

System.Collections.Generic.IEnumerable

..你错过了一个可以用于物品的枚举.将您的代码更改为:

@Html.DropDownList("Scholarship_contactID",new SelectList(new List<string>()),new { @class = "form-control"})

这使用以下重载:

public static MvcHtmlString DropDownList(
    this HtmlHelper htmlHelper,string name,IEnumerable<SelectListItem> selectList,string optionLabel,object htmlAttributes
)

原文地址:https://www.jb51.cc/csharp/98186.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐