我想在 Chosen中使用多项选择。我有类似的技能模型,
public class Skill
{
public int Id { get; set; }
public string Name { get; set; }
}
这适用于我的应用程序:
<select data-placeholder="Choose a Country..." class="chzn-select" multiple >
<option value=""></option>
<option value="United States">United States</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
</select>
我想用我的数据替换国家数据。在控制器中我写:
var list = MyService.LoadAllSkills();
ViewBag.Skills = new MultiSelectList(list, "Id", "Name");
鉴于:
@Html.ListBox("Name", ViewBag.Skills as MultiSelectList,
new { @class = "chzn-select" } )
@Html.ListBox()和@Html.DropDownList()的查看结果不一样<select>
我得到这样的结果:
但是,我想得到结果
如何更改选择的样本?