Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bind large number of data to a combobox?

I want to bind list of employees in drop down list , with autocomplete feature so the user can search the proper name .i use RadComboBox

I have two main problems :

1- The list is so large about 5000 item.so binding this large number of data in the browser make it hang or so slow.(performance issue)

According to the Telerik Documentation

Set a data source to the RadComboBox. Use either DataSourceID or the DataSource property to do this and set the DataTextField and DataValueField properties to the respective fields in the data source. (Note that when using DataSource you must set the property on each postback, most conveniently in Page_Init.) Set EnableAutomaticLoadOnDemand to true.

so i have to call the following method every time in Page_Init !!!

  protected void BindInnerInstructors()
    {
        ddl_inner_sup.Items.Clear();
        ddl_inner_sup.DataSource = Utilities.GetAllInnerInstructors();
        ddl_inner_sup.DataValueField = "emp_num";
        ddl_inner_sup.DataTextField = "name";
        ddl_inner_sup.DataBind();
    }

2- Object reference not set to an instance of an object when trying to set the selection of a combo box.

i overcome this problem through this.


I have about 4 dropdowlists but every one have to bind in according to an event but i have to bind all of them in the page_init.

I'll be grateful to a detailed answer to this problem .

like image 621
Anyname Donotcare Avatar asked May 26 '13 13:05

Anyname Donotcare


1 Answers

my company had a similar issue. we ended up using a jquery object called Select2 and we lazy load the list. Basically we load only the first 10 or so at load time, making it fast to load, and if the user scrolls down past the first 10 we load the next 10 and so on. Select2 has a search feature which hits the server to return a custom list based on the search.

the problem with loading 5000 elements all at once is that the browser will take forever to load them, iterate through them, and manipulate them as needed. I am not saying "you must use select2" RadComboBox may have something like this you can use.

Good luck.

like image 106
Kenneth Garza Avatar answered Oct 05 '22 22:10

Kenneth Garza