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

Switch DataSources Dynamically

2 Answers 53 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
JD Emmert
Top achievements
Rank 1
JD Emmert asked on 12 Nov 2010, 05:52 PM
I have a RadComboBox1 that I want to show nothing in until the RadComboBox2 above it has a selected value.  I do this by not setting a data source on RadComboBox1.  Once a value is selected in RadComboBox2 on the server side I am setting a new datasource and loading the RadComboBox1.  This works the first time I have selected an option in RadComboBox2 that has associated data.  When I select an item in RadComboox2 that does not have associated data, RadComboBox1 will not clear. 

I have tried the following to clear RadComboBox1:

                RadComboBox1.ClearSelection();
            RadComboBox1.Text = string.Empty;
            RadComboBox1.Items.Clear();
            RadComboBox1.DataSource = null;
            RadComboBox1.DataBind();
  
            while (RadComboBox1.Items.Count > 0)
            {
                RadComboBox1.Items.Remove(0);
            }

However nothing seems to allow me to remove the items from RadComboBox1.  I have tried this code on RadComboBox2 selected index changed, on RadComboBox1 items requested and elsewhere.  Any help would be appreciated.

2 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 16 Nov 2010, 03:56 PM
Hi JD Emmert,

Calling Items.Clear() would suffice. Can you please debug and see how many Items are there after calling it? At which point during the page life cycle do you do this - Page_Load, SelectedIndexChanged, etc.?

Kind regards,
Simon
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
JD Emmert
Top achievements
Rank 1
answered on 16 Nov 2010, 05:11 PM
I finally discovered the problem, it was a few stupid, simple mistakes.  I didn't have the control surrounded in an ajax panel and I did not have both of the controls that update the rad drop down box listed in the rad ajax manager.  Thanks for your help though. 
Tags
ComboBox
Asked by
JD Emmert
Top achievements
Rank 1
Answers by
Simon
Telerik team
JD Emmert
Top achievements
Rank 1
Share this question
or