简体   繁体   中英

Loading Tons of data in DropdownList in MVC3

I have Jquery Select2 DropdownList in my MVC3 project. Usually the dropdownlist will have the data minimum of 50000 records. The records passing from controller to view through ViewBag. When its rendering the data to the page gets so much of time to load all the data.

Also when i clicking on the dropdown gives some browser error like stop scripting. I need to know is there any better way to load my content in DropDownList without affecting the page load. I will be attaching my current controller and view code here.

Action

ViewBag.IssueId = new SelectList(Db.Issues, "id", "Description", item.IssueId);

View

    @Html.DropDownList("IssueId", string.Empty)

JQuery Select2 Code

    $('#IssueId').select2({
        placeholder: 'Select Issue',
        width: '220px',
        allowClear: false
    });

No dropdown list should have 50000 records.

This is would be terrible for User Experience .

You need to reconsider how what you are trying to achieve. For instance how would a user be able to make use a drop down with this many options, if it did manage to load. Maybe you could have a filter that would load different sets in a dropdown, this filter itself could be a dropdown.

You should try categorizing (if possible) your List Items into groups.

Eg.:

Group A:items
Group B:items

And so on...

& then you can use cascading dropdownlists for selection.

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