Leave the HTML.DropDownList () with the Bootstrap style?

1

I have DropDownList in my View and despite having class form-control the list does not have the style of Bootstrap .

How can I edit how DropDownList builds lists?

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

Since I have the whole site based on Bootstrap , I do not want to miss this element. I have the project in MVC4 .

    
asked by anonymous 23.03.2017 / 15:18

1 answer

0

Apparently everything is all right. I suggest another construction to better handle 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" })
    
05.05.2017 / 20:13