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

c# – 将Bootstrap类应用于@ Html.DropDownList(),第1张

概述我正在尝试将引导样式应用于以下下拉列表: @Html.DropDownList("Scholarship_contactID", "-- Select Contact --", new { @class = "form-control"}) 这将返回以下错误: ‘System.Web.Mvc.HtmlHelper’ does not contain a definition for ‘DropDo 我正在尝试将引导样式应用于以下下拉列表:
@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)
总结

以上是内存溢出为你收集整理的c# – 将Bootstrap类应用于@ Html.DropDownList()全部内容,希望文章能够帮你解决c# – 将Bootstrap类应用于@ Html.DropDownList()所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1240830.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存