This is a migrated thread and some comments may be shown as answers.

RadComboBox Item Duplicate

6 Answers 490 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Srujan
Top achievements
Rank 1
Srujan asked on 27 Apr 2011, 11:36 PM
Hi ,

I have RadCombo box which is using ItemRequested event to load items , when I click on "ShowMoreResults" list of items are added again and total count is doubled  . I used RadCombo box clear items before rebinding but still the issue occurs ,can anybody suggest how to go about the issue .

Regards
Srujan.N

6 Answers, 1 is accepted

Sort by
0
Charles
Top achievements
Rank 1
answered on 26 Sep 2012, 03:24 PM
Did you ever find an answer to your question? I have the same problem. When I click the more items control, I get duplicate items.
0
Ivana
Telerik team
answered on 29 Sep 2012, 10:32 AM
Hello Srujan and Charles,

Take a look at the following help article explaining on how to implement the ShowMoreResultsBox/Virtual Scrolling functionality: https://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/load-on-demand/showmoreresultsbox-virtual-scrolling. If you, however, are using automatic load on demand then all this should be taken care of internally.

If you still have troubles, could you paste here the markup of the control and the code involved in the troubled behavior?

Regards,
Ivana
the Telerik team
 
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
 
0
Fred
Top achievements
Rank 1
answered on 13 Dec 2012, 07:53 PM
Hi,

I do have the same exact issue. Whenever I click on ShowMoreResults, the items get duplicated. I searched online for a solution, but I could not find anything. 

Regards.
0
Princy
Top achievements
Rank 2
answered on 14 Dec 2012, 04:11 AM
Hi Fred,

I suppose you are missing the server-side logic in the ItemsRequested event handler that loads only the needed portion of Items.

C#:
protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
    string sql = "SELECT * from Customers WHERE CompanyName LIKE '" + e.Text + "%'";
    SqlDataAdapter adapter = new SqlDataAdapter(sql, ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
    DataTable data = new DataTable();
    adapter.Fill(data);
    //loads only the needed portion of Items
    try
    {
        int itemsPerRequest = 10;
        int itemOffset = e.NumberOfItems;
        int endOffset = itemOffset + itemsPerRequest;
        if (endOffset > data.Rows.Count)
        {
            endOffset = data.Rows.Count;
        }
        for (int i = itemOffset; i < endOffset; i++)
        {
            RadComboBox1.Items.Add(new RadComboBoxItem(data.Rows[i]["CompanyName"].ToString(), data.Rows[i]["CompanyName"].ToString() + "'"));
        }
        if (data.Rows.Count > 0)
        {
            e.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString());
        }
        else { e.Message = "No matches"; }
    }
    catch
    {
        e.Message = "No matches";
    }
}

Please take a look into this documentation and demo for the complete code.

Please provide your full code if doesn't helps.

Regards,
Princy.
0
Matt
Top achievements
Rank 1
answered on 10 Jul 2018, 03:47 PM
Please post solutions and not links to solutions. Telerik pages are not maintained to redirect to the correct information.
0
Peter Milchev
Telerik team
answered on 11 Jul 2018, 08:36 AM
Hello Matt,

We are sorry for the broken redirect. The correct link is https://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/load-on-demand/showmoreresultsbox-virtual-scrolling.

Also, Princy has provided the solution and also a live example can be found in the Online Demos - https://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx.

Generally, the idea is to load only the records that are requested by the control instead of all records: 

for (int i = itemOffset; i < endOffset; i++)
{
    RadComboBox1.Items.Add(new RadComboBoxItem(data.Rows[i]["CompanyName"].ToString(), data.Rows[i]["CompanyName"].ToString() + "'"));
}

Regards,
Peter Milchev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
Srujan
Top achievements
Rank 1
Answers by
Charles
Top achievements
Rank 1
Ivana
Telerik team
Fred
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Matt
Top achievements
Rank 1
Peter Milchev
Telerik team
Share this question
or