我正在使用bootstrap显示下拉列表。问题是样式没有应用于下拉列表。
当我查看它显示的源代码时......
<div class="form-group">
<label class="control-label col-md-2" for="State">State</label>
<div class="col-md-10">
<select htmlAttributes="{ class = form-control }" id="State" name="State"><option
value="CT">CT</option>
为什么类形式控件没有被添加到select标签?
<div class="form-group">
@Html.LabelFor(m => m.State, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(m => m.State, db.StateDiscountRates.Select(c => new SelectListItem { Value = c.State, Text = c.State }).ToList().OrderBy(c => c.Text)
.GroupBy(test => test.Text)
.Select(group => group.First()), new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Address, "", new { @class = "text-danger" })
</div>
</div>