Load on demand and selected item in selectedindexchanged

4 posts, 0 answers
  1. Peter
    Peter avatar
    1 posts
    Member since:
    Mar 2009

    Posted 03 Mar 2010 Link to this post

    Hi guys,

    I have a RadComboBox as follows
    <radcontrol:RadComboBox ID="MessageRecepientsSelectorComboBox" runat="server" EnableLoadOnDemand="true"    
        LoadingMessage="Loading..." EmptyMessage="Please enter recepient(s) for the message..."   
        OnItemsRequested="MessageRecepientsSelectorComboBox_OnItemsRequested" Width="450" ShowDropDownOnTextboxClick="false" 
        Filter="StartsWith" OnSelectedIndexChanged="MessageRecepientsSelectorComboBox_OnSelectedIndexChanged" 
        AutoPostBack="true" EnableItemCaching="true"></radcontrol:RadComboBox> 

    Which is inside a Load on demand RadPageView (incase that is relevant).

    The ComboBox works fine for getting and matching values (names in this case) however in the SelectedIndexChanged my RadComboBox.SelectedItem is null, RadComboBox.Items.Count = 0. See below

    protected void MessageRecepientsSelectorComboBox_OnItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)  
            RadComboBox recepientSelectorComboBox = (RadComboBox)sender;  
            if (!e.Text.Equals("") && e.Text.Length >= 1)  
                List<Controls_RecepientsSelectorAJAXDropDownResult> potentialRecepients = MemberContactStaticRepository.GetRecepientsForAJAXSelector(53, e.Text);  
                RadComboBoxItem currentItem = new RadComboBoxItem(); //stop re initialising var in loop  
                for(int i = 0;i < potentialRecepients.Count();i++)  
                    currentItem = new RadComboBoxItem(potentialRecepients[i].UserName, potentialRecepients[i].UserID.ToString());  
                    //currentItem.Attributes["ContactType"] = "User";  

    protected void MessageRecepientsSelectorComboBox_OnSelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)  
            RadComboBox recepientBox = (RadComboBox)sender;  
            //RadComboBoxItem selectedItem = MessageRecepientsSelectorComboBox.FindItemByValue(e.Value); //finds nothing == null  
            //MessageRecepientsSelectorComboBox.Items.Count; // is 0          
            //MessageRecepientsSelectorComboBox.SelectedIndex;//returns -1       

    Please note in the OnSelectedIndexChanged it is all commented out but the comments beside it tell you what happens.
    I need it to have a SelectedItem so that i can access the Attributes i need to set.

    Thanks in advance,
  2. Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 09 Mar 2010 Link to this post

    Hi Peter,

    ComboBox items are not accessible on the server-side when loading them on demand

    What you can do in this case is to use hidden fields and store the necessary attributes in their values.

    Let me know if I can assist you further.

    Sincerely yours,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Bala
    Bala avatar
    11 posts
    Member since:
    Aug 2012

    Posted 12 Sep 2012 Link to this post


    I am also facing the same issue. Please assist me in fixing this issue.

    Yours Sincerely
  4. Ivana
    Ivana avatar
    657 posts

    Posted 12 Sep 2012 Link to this post

    Hello Bala,

    The help article provided by Veselin (ComboBox items are not accessible on the server-side when loading them on demand) explains a lot on why it is essential to not have the items of RadComboBox accessible on the server when the control is loaded on demand.

    The help article also explains on the RadComboBox's properties that are accessible on the server.

    I hope you'll  find this helpful!

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