加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 18:19:39 所属栏目:百科 来源:网络整理
导读:我正在尝试将引导样式应用于以下下拉列表: @Html.DropDownList("Scholarship_contactID","-- Select Contact --",new { @class = "form-control"}) 这将返回以下错误: ‘System.Web.Mvc.HtmlHelper’ does not contain a definition for ‘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
)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读