Last post Mar 25, 2016 07:49 AM by Yohann Lu
Mar 24, 2016 07:23 PM|march11|LINK
This question has been asked before, but it seems that everyone that answers doesn't truly understand the problem. This issue focuses on the Dropdown List box and problems setting the width WHEN THEN CONTROL IS ACTIVATED, not when it is present on the page.
All posts that I have read repeatedly indicate various solutions for setting the width, CSS, Databound event etc. All work when it comes to the control being loaded on the page. The issue was primarily in older browsers when the control did not widen to
display the full width of the list items on each row. for example...
item1 - a regular width
item2 - a little bit longer width
item3 - a very much longer width of content that needs to be displayed when the user clicks the drop down arrow.
item4 - a little shorter and normal
My issue, and what repeatedly gets directed to one of the other solutions mentioned above, sis that very long content does not wrap, and instead causes the control to widen to the full width of the display.
item5 - A very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very,very, very, very, very, very, very, very, very, long test string which must be displayed in the DDL.
I have a very long list of items tens of thousands and the DDL works well to scroll through them to locate a single record. It just so happens that very few of them (Which can not be changed) are rather long/wide. 24 inch monitor wide. which destroys the
display of the page.
Is there a standard .NET solutions for handling this ?
Mar 25, 2016 07:49 AM|Yohann Lu|LINK
From your description, I have made a sample on my side and reproduce your problem.
I found the DropDownListChosen control can solve your problem.
Firstly, you should install DropDownListChosen from the nuget package like the below.
Secondly, you can refer to the following code in my project.
<form id="form1" runat="server">
<%-- <asp:DropDownList ID="DropDownList1" runat="server" Height="16px" Width="175px"></asp:DropDownList>--%>
<asp:DropDownListChosen ID="DropDownListChosen1" runat="server"
NoResultsText="No results match." Width="350px"
DataPlaceHolder="Type Here..." AllowSingleDeselect="true">
protected void Page_Load(object sender, EventArgs e)
List<string> lists = new List<string>();
DropDownListChosen1.DataSource = lists;
Also, you can try to custom dropdownlist control in asp.net.