Switch DataSources Dynamically

3 posts, 0 answers
  1. JD Emmert
    JD Emmert avatar
    5 posts
    Member since:
    Aug 2009

    Posted 12 Nov 2010 Link to this post

    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. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 16 Nov 2010 Link to this post

    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.
  3. JD Emmert
    JD Emmert avatar
    5 posts
    Member since:
    Aug 2009

    Posted 16 Nov 2010 Link to this post

    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. 
Back to Top