0

We are displaying all the US cities in the dropdown list. But when i scroll down the dropdown and select some value, then browser gets hanged up. Please let me know if there is any solution to fix it.

<div class="customselectdiv custom-req" id="divCity" runat="server" visible="false">
      <asp:DropDownList ID="ddlCity" runat="server" TabIndex="10" class="customselect required"     Visible="false" AutoPostBack="true" OnSelectedIndexChanged="ddlCity_SelectedIndexChanged"></asp:DropDownList>
</div>

And the cities are binding the dropdown from the database.

8
  • 10
    Do you consider this easy to use? Are you absolutely 100% sure that you can't go for a different approach - like a textfield with autocomplete suggestions? Oct 7, 2014 at 13:14
  • There is absolutely no excuse for what you are doing... please stop... there are many ways how to do it better... (e.g. jeroens comment)
    – sasjaq
    Oct 7, 2014 at 13:19
  • 1
    Nobody got time to scroll 50k records!
    – Renatas M.
    Oct 7, 2014 at 13:21
  • 1
    "This is the requirement by the client that i need to fulfill" - tell the client they're wrong or accept that you misinterpreted that requirement.
    – CodeCaster
    Oct 7, 2014 at 14:20
  • 1
    To the best of my knowledge (feel free to correct me, guys) there is no way to do virtual scrolling in a DropDownList in ASP.NET. There just plain isn't. You can get something that looks similar to a DropDownList, for which people have given you links in answers, but 50,000 of anything in a web page is going to be an error-prone memory hog. And it will hang.
    – Ann L.
    Oct 7, 2014 at 17:27

3 Answers 3

8

There is no way for a browser's SELECT control to handle 50,000 items. There is no way for a user's screen to handle 50,000 items.

You will have to create your own custom html control. I suggest something like what wowhead does. Create a search box, and have the "drop down" appear that shows 10 items that contain the entered text anywhere:

enter image description here

But to answer your actual question:

No, there is no way to fix it. The web-site is not supposed to be presenting the user with 50,000 drop-down items.

3
  • +1 I like this: "then your user interface design is in serious need of rethought, because you just created a usability nightmare." Oct 7, 2014 at 13:21
  • this is also bad advice when you have big collections. What if I have 1000 items which are similar but I don't remember the exact name ? The wanted result will never be seen. This not fully answered question but ok, this is a little part of the solution. Oct 7, 2014 at 13:32
  • I would use this solution in conjunction with a filtered search; depending on country, start by narrowing down by region/county/state. Oct 7, 2014 at 14:04
2

You're not going to be able to add 50000 records to that select box, I'd recommend looking into a city autocomplete like the one Google offers.

0

you can use bootstrap dopdown in your appication bootstrap provide search functionality.

I have created dropdown with searcch using bootstrap you can use it.

follow below link, here i have provided example of dropdown.

Dropdown List with search

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.