简体   繁体   中英

Dropdown list in ASP.NET Core 2.2

I have some huge files which has some 300,000 + Id's and I am able to display the ID's in a dropdown, but it takes a long time to open the dropdown and select the value.

I have created dropdown using the following code:

<select asp-for="SelectIDs" asp-items=@Model.pvalues onclick="this.size=1;" onMouseOver="this.size=10;" onMouseOut="this.size=1;" style="padding:10px;position:absolute;">
    <option value="" selected>Select ID..</option>
</select>

May I know what needs to be done to handle such huge dropdown lists please?

I can't apparently leave a comment yet, otherwise I would do that. But I would suggest if at all possible, you need to do some pre-filtering.

Are there absolutely no selections you could ask the user to make first that would reduce the size of this dropdown?

Some thoughts (Random, as I don't know what your data set is):

  • Country/State
  • Industry
  • Date Range
  • Manual input filter
  • Etc.

The best option is to use a dynamic dropdown with search box, the items list will update via ajax when the user types some characters in it.

See https://select2.org/data-sources/ajax

Is it possible to post a sample of each of the two files? Doesn't have to contain actual data, just dummy values to understand schema.

FYI, I think your statement I have two huge xml files which has 300,000 + ID's and User has to select an ID must be wrong. In such cases the best way to look into the problem is question is not 'select and ID' but 'the user has to select an entry and the ID will be used by the solution to do something else'. As others have pointed out, expecting a user to select from a 300K+ list or expect a page to load the list is a definite usability issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM