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

[Solved] Multiple Items in RadComboBox

2 Answers 159 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Test Test
Top achievements
Rank 1
Test Test asked on 11 Dec 2009, 11:31 AM
I've got a problem with filling RadComboBox. Every time, the user clicks on the scrollbar all items are added again.

My RadComboBox looks like (its within a table):

 

                                                        <telerik:RadComboBox ID="radComboBoxPLZ" Runat="server" Width="50px" DropDownWidth="260px" MaxHeight="200px" 
                                                            OnItemsRequested="radComboBoxPLZ_ItemsRequested" EnableLoadOnDemand="true" MarkFirstMatch="true"   
                                                            CollapseDelay="100" TabIndex="1">  
                                                            <HeaderTemplate> 
                                                            <table style="width: 220px" cellspacing="0" cellpadding="0">  
                                                                <tr> 
                                                                    <td style="width: 40px;">  
                                                                        PLZ</td> 
                                                                    <td style="width: 120px;">  
                                                                        Gemeinde</td> 
                                                                    <td style="width: 20px;">  
                                                                        Kanton</td> 
                                                                </tr> 
                                                            </table> 
                                                            </HeaderTemplate> 
                                                            <ItemTemplate> 
                                                                <table style="width: 220px" cellspacing="0" cellpadding="0">  
                                                                    <tr> 
                                                                        <td style="width: 40px;">  
                                                                            <%# DataBinder.Eval(Container, "Text")%> 
                                                                        </td> 
                                                                        <td style="width: 120px;">  
                                                                            <%# DataBinder.Eval(Container, "Attributes['Gemeinde']")%> 
                                                                        </td> 
                                                                        <td style="width: 20px;">  
                                                                            <%# DataBinder.Eval(Container, "Attributes['Kanton']")%> 
                                                                        </td> 
                                                                    </tr> 
                                                                </table> 
                                                            </ItemTemplate> 
                                                        </telerik:RadComboBox> 
 
And my CS-Code looks like:
    protected void radComboBoxPLZ_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)  
    {  
        if (e.Text.Length < 1)  
            return;  
 
        string sqlSelectCommand = string.Format("Select p.PLZ, k.Gemeinde, k.Kanton from AAV_TEST_PLZ_ORTE_GEMEINDE p, AAV_TEST_GEMEINDE_KANTON k where p.KANT_GEM_ID = k.ID and p.PLZ LIKE '{0}%' ORDER BY p.PLZ", e.Text);  
 
        DataTable dataTable = null;  
 
        using (OleDbDataAdapter adp = new OleDbDataAdapter(sqlSelectCommand, AdresssucheParameter.ConnectionString))  
        {  
            dataTable = new DataTable();  
            adp.Fill(dataTable);  
        }  
 
        foreach (DataRow dataRow in dataTable.Rows)  
        {  
            RadComboBoxItem item = new RadComboBoxItem();  
 
            item.Text = (string)dataRow["PLZ"];  
            item.Value = dataRow["PLZ"].ToString();  
 
            //zusätzliche Spalten  
            item.Attributes.Add("Gemeinde", dataRow["Gemeinde"].ToString());  
            item.Attributes.Add("Kanton", dataRow["Kanton"].ToString());  
 
            radComboBoxPLZ.Items.Add(item);  
            item.DataBind();  
        }  
    }  
 
In den Page_Load-Event I do nothing, beceause I don't want to load all the items beacause it takes too long. And I can't use WebService, because I need to get the value from the ComboBox in an other ComboBox with:

    string

plz = e.Context["FilterStringPLZ"].ToString();

I'm looking for an solutin since 2 days and can't find an answer. It's very frustrating because I'm testing with yout Trial Version - when it looks good, we would like to pay the software.
Thanks for your anser! Bye

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Simon
Telerik team
answered on 11 Dec 2009, 01:08 PM
Hi Test Test,

Can you please specify which version of the Telerik.Web.UI assembly you are using? We have resolved this issue shortly after the official Q3 2009 release, so please make sure that you are using the latest version.

All the best,
Simon
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Test Test
Top achievements
Rank 1
answered on 11 Dec 2009, 03:27 PM
Thanks for the extremly quick reply!!! I can't believe it...

I changed my scripts an use WebMethods now. I found how to use the context variable.
Thank you! Bye
Tags
ComboBox
Asked by
Test Test
Top achievements
Rank 1
Answers by
Simon
Telerik team
Test Test
Top achievements
Rank 1
Share this question
or