'How to get bootstrap dropdown list style on asp:DropDownList without using form-control class

I'm attempting to add bootstrap style to an old application. One thing I have come across repeatedly is wanting to style an asp:DropDownList as a bootstrap dropdown.

I came across a SO post that said to use the form-control class. This actually works however it gives the control a width of 100% thanks to the form-control class which is taking priority over the grid's width.

I have been trying to figure out how to get it to prioritize the grid width, however I wonder that applying form-control is the wrong solution in the first place.

I would definitely prefer not to rewrite the asp:DropDownList using a button and ul as done in bootstrap examples b/c I would have to repeat this transformation a hundred times and it's simply not worth it.



Solution 1:[1]

Hum, you could add a width to the dropdownlist like this:

        <asp:DropDownList ID="DropDownList1" CssClass="form-control" runat="server"
            DataValueField="ID"
            DataTextField="HotelName"
            width="180px"
            ></asp:DropDownList>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Albert D. Kallal