Leave HTML.Dropdownlist() in Bootstrap style?

Asked

Viewed 433 times

1

I have a DropDownListin my View and despite having the class form-control the list does not take the style of the Bootstrap.

How can I edit the way DropDownList builds the lists?

@Html.DropDownList("countriesDiretorySelect",
              new SelectList(ViewBag.Countries as System.Collections.IEnumerable,
              "NumKeyId",
              "VarResourceLevelName"),
              new { id = "countriesDiretorySelect", @class = "form-control " })

As I have the whole site based on Bootstrap, do not want to let escape this element. I have the project in MVC4.

1 answer

0

Apparently everything is right. I suggest another construction to better manipulate your Dropdown:

@Html.DropDownListFor(model => model.countriesDiretorySelect,
              ((IEnumerable<Country>)ViewBag.Countries).Select(c => new SelectListItem {
                  Value = c.NumKeyId.ToString(),
                  Text = c.VarResourceLevelName,
                  Selected = (Model != null) && (Model.countriesDirectorySelect == c.NumKeyId)
              }), "Selecione...", new { id = "countriesDiretorySelect", @class = "form-control" })

Browser other questions tagged

You are not signed in. Login or sign up in order to post.