以前我使用标准复选框,但现在我想使用bootstrap Multiple选择框。
此时我在下拉列表中看不到任何行。
我的新代码:
<li>
<select href="#" class="selectpicker" data-value="option1" tabIndex="-1" multiple data-selected-text-format="count">
<option checked> @Html.DisplayTextFor(model => Model.AvailableCompanies[i].NAME)</option>
<option name="selection[@i]" value="true"></option>
<option name="ids[@i]" value="@Model.AvailableCompanies[i].ID"></option>
</select></li>
我之前的代码:
<li>
<a href="#" class="small" data-value="option1" tabIndex="-1">
<input type="checkbox" checked /> @Html.DisplayTextFor(model => Model.AvailableCompanies[i].NAME)
<input type="hidden" name="selection[@i]" value="true"/>
<input type="hidden" name="ids[@i]" value="@Model.AvailableCompanies[i].ID" />
</a>
答案 0 :(得分:0)
在C#中,我们有很酷的助手和多选按钮
@Html.ListBoxFor(model => model.Companies,
new MultiSelectList(Model.AvailableCompanies, "ID", "NAME", null),
new
{
data_dropdown_align_right = "auto",
id = "",
data_selected_text_format = "count",
data_actions_box = "true",
@class = "selectpicker form-control",
multiple = "multiple",
data_live_search = "true"
})