Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a DevEx GridView and inside that I have GridViewDataComboBoxColumn. I need to fill the Combo-box with 7500 rows. I have used the following query in stored procedure sp_select_AllStocks

SQL
Select StockId,StockName from StockMaster;


The below code is used in aspx.cs page to dynamically bind combobox.

C#
DataTable dt_fill_StocksCombo = new DataTable();
                dt_fill_StocksCombo = con.select_AllStocks();
                ((GridViewDataComboBoxColumn)gdStocks.Columns["StockName"]).PropertiesComboBox.IncrementalFilteringMode = DevExpress.Web.ASPxEditors.IncrementalFilteringMode.StartsWith;
                ((GridViewDataComboBoxColumn)gdStocks.Columns["StockName"]).PropertiesComboBox.DropDownStyle = DevExpress.Web.ASPxEditors.DropDownStyle.DropDown;
                ((GridViewDataComboBoxColumn)gdStocks.Columns["StockName"]).PropertiesComboBox.DataSource = dt_fill_StocksCombo;
                ((GridViewDataComboBoxColumn)gdStocks.Columns["StockName"]).PropertiesComboBox.ValueField = "StockId";
                ((GridViewDataComboBoxColumn)gdStocks.Columns["StockName"]).PropertiesComboBox.TextField = "StockName";


The function definition of select_AllStocks() is as follows.

C#
public DataTable select_AllStocks()
       {
           Open_Connection();
           DataTable dt = new DataTable();
           cmd = new SqlCommand("sp_select_AllStocks", con);
           cmd.CommandType = CommandType.StoredProcedure;
           SqlDataAdapter adt = new SqlDataAdapter(cmd);
           adt.Fill(dt);
           Close_Connection();
           return dt;
       }



The above method takes approximately 30 seconds to load combobox with 7500 rows.
Is there a way out to increase the performance?
Posted
Comments
Richard MacCutchan 11-Mar-15 4:20am    
Only a complete novice (or fool) would want to load that many rows at one time. Do you really want to make your users scroll through that much information trying to find the item they want?
Member 11410952 11-Mar-15 4:23am    
IncrementalFilteringMode would enable the user to write a letter and get the relevant StockName from the dropdown...something like intelliSense. So the user ll not need to scroll through these many rows.
Richard MacCutchan 11-Mar-15 5:11am    
Then you must accept the problem that loading 7500 rows will take a long time.
[no name] 11-Mar-15 5:47am    
The idea to load 7500 items into a ComboBox is indeed questionable but 30s seems way too much nonetheless. I suggest you do some basic profiling (with System.Diagnostics.Stopwatch) to find out which parts of the whole process take how long (querying / loading the Datatable / transport to Client / actually loading the ComboBox / something else you can identify as potential time consuming part of the process). Then add that information to your question and we can probably help to improve it.
Member 11410952 11-Mar-15 11:49am    
Let me tell you the exact scenario. I have created a stored procedure which takes 130 ms and if run query directly, it takes 120 ms.

I suspect that querying / loading the Datatable / transport to Client is not taking much time but loading the ComboBox takes more time than expected.

I can use the intelliSense of combo box where I can write 1-2 letter and it will search based on that but in this case, I have to fill all 7800 rows in the combo box. If it is not require to fill all the rows once, where (in which event) can I write the code to fill after entering 1-2 characters.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900