ComboBox has duplicated values and set footer message

2 posts, 1 answers
  1. Headache
    Headache avatar
    2 posts
    Member since:
    Apr 2015

    Posted 04 Nov 2015 Link to this post

    I have created a function to combine all ComboBox SQL statement into it,  it is work for showing the data value, but I found that when I click the footer message, it will show up duplicated records in the ComboBox value. Did I miss something? Is it the proper way to do it? Thanks in advance. 


    My questions are:

    1. How to prevent duplicated value? I did try to use EnableAutomaticLoadOnDemand="true", but I have got another error : "There is no assigned datasource. unable to complete callback request".

    2. How can I set the paging into the ComboBox like the Demo "Items 1 of 20 out of 90", seems I cannot pass the NumberOfItems parameter into it.


    My Code as below:


            public void BindCombobox()
                    //Default parameters
                    AllowCustomText = true;
                    Filter = RadComboBoxFilter.Contains;
                    MarkFirstMatch = true;
                    EnableAutomaticLoadOnDemand = false;
                    ShowMoreResultsBox = true;
                    EnableVirtualScrolling = true;
                    ItemsPerRequest = 20;

                    string connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["Context"].ConnectionString;
                    SqlConnection cs = new SqlConnection(connectionstring);
                    SqlCommand cmd = new SqlCommand();

                    switch (this.ID)
                        case "cbTestA":
                                cmd.CommandText = "select id as dtxt,id as dval from COMPANY";
                        case "cbTestB":
                                cmd.CommandText = "select id as dtxt,id as dval from COUNTRY";
                        case "cbTestC":
                                cmd.CommandText = "select id as dtxt,id as dval from USERNAME";

                    cmd.Connection = cs;
                    DataSet dset = new DataSet();
                    SqlDataAdapter dp = new SqlDataAdapter(cmd);

                    DataSource = dset;
                    DataTextField = "dtxt";
                    DataValueField = "dval";

                    //int itemOffset = this.NumberOfItems;
                    //int endOffset = Math.Min(itemOffset + ItemsPerRequest, 20); //dset.Rows.Count);
                    //this.EndOfItems = endOffset == 20; // data.Rows.Count;
                    //this.Message = GetStatusMessage(endOffset, 20); //data.Rows.Count);
                catch (Exception)

  2. Answer
    Nencho avatar
    1874 posts

    Posted 06 Nov 2015 Link to this post

    Hello Tim,

    The ItemsPerRequest property will be applicable in scenario, where the EnableAutomaticLoadOnDemand property is enabled for the RadComboBox. In such case, you only need to supply the control with the SQLDataSource and the portioning will be automatically calculated.

    However, in a scenario, where you need to use ItemsReqested event handler to populate the control with data in simple LoadOnDemand scenario, you have to implement the items per request manually.

    Below you can find our online demos, regarding the two cases:

    In addition, as we are currently discussing this topic in the support ticket that you have submitted on the matter, I would like to ask you to continue the correspondence in the other thread, in order to avoid duplication.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top