带有bootsrap的mvc下拉列表

时间:2016-04-26 06:26:05

标签: jquery css asp.net asp.net-mvc twitter-bootstrap

我希望有可搜索的下拉列表like this link

我正在使用ASP.NET MVC

<td class="input">
    <select id="classLessonSelect">
        @foreach (Student student in Model) {
            <option value=@student.id>@student.Name @student.Surname</option>
        }
     </select>
</td>

我无法做到,我怎样才能将它集成到我的代码中? 提前致谢

3 个答案:

答案 0 :(得分:0)

您是否考虑使用Select2 https://select2.github.io/之类的插件。它有很多选项,其中一个是可搜索的选择。设置很容易,例如

$( “#SELECTID”)SELECT2();

答案 1 :(得分:0)

当我需要使用多选项选项进行搜索下拉时,我使用了SumoSelect

为此,我使用jQuery.Ajax调用将数据绑定为动态下拉。

免责声明:获取选定的价值和此类内容需要大量工作,因为这是基于HTMLJavaScript,因此无法访问代码背后的传统ASP.Net的下拉列表。

答案 2 :(得分:0)

<强>第一 您错过了tags selectpicker <{1}}的{​​{1}}个<select></select>上的部分详细信息

它应该像下面这样:

<td class="input">
    <select id="classLessonSelect" class="selectpicker" data-show-subtext="true" data-live-search="true">
        @foreach (var student in Model) {
            <option value=@student.id data-subtext="someSubText">@student.Name @student.Surname</option>
        }
     </select>
</td>

<强>第二

您需要查看项目BootStrap中是否已存在此插件,否则根据您发布的链接,您需要此http://silviomoreto.github.io/bootstrap-select/

相关问题