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

Related Radcombobox

1 Answer 43 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
sam
Top achievements
Rank 1
sam asked on 20 Sep 2010, 10:38 AM
I add the Related Radboboxes (like city combobox and state combobox) as a usercontrol , there is a problem when i use this usercontrol twice in the same page, when i click the first usercontrol  state Combobox it will load the city combobox which is the second usercontrol not the first usercontrol. anybody can help me?
<script type="text/javascript">
    //global variables for the countries and cities comboboxes
    var countriesCombo;
    var citiesCombo;
  
    function pageLoad() {
        // initialize the global variables
        // in this event all client objects 
        // are already created and initialized 
        countriesCombo = $find("<%= ddlState.ClientID %>");
        citiesCombo = $find("<%= ddlCity.ClientID %>");
    }
  
    function GetStateList(combo, eventArqs) {
        var item = eventArqs.get_item();
        countriesCombo.set_text("Loading...");
        citiesCombo.clearSelection();
  
        // if a continent is selected
        if (item.get_index() > 0) {
            // this will fire the ItemsRequested event of the 
            // countries combobox passing the continentID as a parameter 
            countriesCombo.requestItems(item.get_value(), false);
        }
        else {
            // the -Select a continent- item was chosen
            countriesCombo.set_text(" ");
            countriesCombo.clearItems();
  
            citiesCombo.set_text(" ");
            citiesCombo.clearItems();
        }
    }
  
    function GetCityList(combo, eventArqs) {
        var item = eventArqs.get_item();
  
        citiesCombo.set_text("Loading...");
        // this will fire the ItemsRequested event of the
        // cities combobox passing the countryID as a parameter 
        citiesCombo.requestItems(item.get_value(), false);
    }
  
    function ItemsLoaded(combo, eventArqs) {
        if (combo.get_items().get_count() > 0) {
            // pre-select the first item
            combo.set_text(combo.get_items().getItem(0).get_text());
            combo.get_items().getItem(0).highlight();
        }
        combo.showDropDown();
    }
  
</script>
<tr>
        <td><asp:Label ID="Label1" runat="server" AssociatedControlID="ddlState">stateļ¼š</asp:Label></td>
        <td>
            <telerik:RadComboBox ID="ddlState" runat="server" Height="200"
                OnClientSelectedIndexChanging="GetCityList" OnClientItemsRequested="ItemsLoaded" 
                OnItemsRequested="ddlState_ItemsRequested" >
            </telerik:RadComboBox>
        </td>
        <td></td>
    </tr>
    <tr>
        <td><asp:Label ID="Label3" runat="server" AssociatedControlID="ddlCity">cityļ¼š</asp:Label></td>
        <td>
            <telerik:RadComboBox ID="ddlCity" runat="server" Height="200"
                OnClientItemsRequested="ItemsLoaded"
                OnItemsRequested="ddlCity_ItemsRequested">
            </telerik:RadComboBox>
        </td>
        <td></td>
    </tr>
    <tr>
        <td><asp:Label ID="Label2" runat="server" AssociatedControlID="ddlCountryID">contryļ¼š</asp:Label></td>
        <td>
            <telerik:RadComboBox ID="ddlCountryID" runat="server" Height="200"
                OnClientSelectedIndexChanging="GetStateList"
                OnItemsRequested="ddlCountryID_ItemsRequested">
            </telerik:RadComboBox>
        </td>
        <td></td>
    </tr>
<uc3:Address ID="ucBillingAddress" runat="server" 
                    DefaultMode="Edit"
                    ValidationGroup="address"
                    AddressID='<% #Bind("AddressID") %>'
                    FirstName='<% #Bind("FirstName") %>'
                    CompanyName='<% #Bind("CompanyName") %>'
                    PhoneNo='<% #Bind("PhoneNo") %>'
                    FaxNo='<% #Bind("FaxNo")%>'
                    Address1='<% #Bind("Address1") %>'
                    Address2='<% #Bind("Address2") %>'
                    CityID='<% #Bind("CityID") %>'
                    StateID='<% #Bind("StateID") %>'
                    CountryID='<% #Bind("CountryID") %>'
                    ZIPCode='<% #Bind("ZIPCode") %>'
                    />
<uc3:Address ID="ucShippingAddress" runat="server" 
                DefaultMode="Edit"
                ValidationGroup="address"
                AddressID='<% #Bind("AddressID") %>'
                FirstName='<% #Bind("FirstName") %>'
                CompanyName='<% #Bind("CompanyName") %>'
                PhoneNo='<% #Bind("PhoneNo") %>'
                FaxNo='<% #Bind("FaxNo")%>'
                Address1='<% #Bind("Address1") %>'
                Address2='<% #Bind("Address2") %>'
                CityID='<% #Bind("CityID") %>'
                StateID='<% #Bind("StateID") %>'
                CountryID='<% #Bind("CountryID") %>'
                ZIPCode='<% #Bind("ZIPCode") %>'
                />

1 Answer, 1 is accepted

Sort by
0
sam
Top achievements
Rank 1
answered on 20 Sep 2010, 10:42 AM
by the way, the usercontrol if only use one time in the page. it will works ok.
Tags
ComboBox
Asked by
sam
Top achievements
Rank 1
Answers by
sam
Top achievements
Rank 1
Share this question
or