Resetting a RadComboBox...

5 posts, 0 answers
  1. mark baer
    mark baer avatar
    142 posts
    Member since:
    Sep 2009

    Posted 02 May 2011 Link to this post

    I have two RadComboBoxes on my page that I can not reset.  Below is their definition and the code behind I am using to reset them.  I have two other RadComboboxes on that same page that I CAN reset.  The main difference is that the two I can not reset are "LoadOnDemand".  I've searched the forums and found a few people with the same problems, but I don't see an answer that works yet.

    See attached image for example...

    Help?

    Thanks

    Mark

    HTML:
    <telerik:RadComboBox ID="cboAgencies" runat="server" EmptyMessage="Type to 
    Search..."<BR>                                                            
    EnableAutomaticLoadOnDemand="true" EnableVirtualScrolling="true" 
    ItemsPerRequest="100"<BR>                                                            
    AutoPostBack="true" MarkFirstMatch="True" Skin="WebBlue" Width="205px" 
    OnSelectedIndexChanged="cboAgencies_SelectedIndexChanged"><BR>                                                            
    <WebServiceSettings Method="GetAgencies" Path="Talent.aspx" 
    /><BR>                                                        
    </telerik:RadComboBox><BR><BR> <telerik:RadComboBox ID="cboAgents" 
    runat="server" EmptyMessage="Type to 
    Search..."<BR>                                                            
    EnableAutomaticLoadOnDemand="true" EnableVirtualScrolling="true" 
    ItemsPerRequest="100"<BR>                                                            
    MarkFirstMatch="True" Skin="WebBlue" Width="205px" AutoPostBack="true" 
    OnSelectedIndexChanged="cboAgents_SelectedIndexChanged"><BR>                                                            
    <WebServiceSettings Method="GetAgents" Path="Talent.aspx" 
    /><BR>                                                        
    </telerik:RadComboBox><BR>

    Code Behind(on a Button Click):

     

    <P>cboAgencies.Text = null;    //Also tried 
    ""<BR>cboAgencies.SelectedValue = null;<BR>cboAgencies.ClearSelection();</P>
    <P><BR>cboAgents.Text = null;<BR>cboAgents.SelectedValue = 
    null;<BR>cboAgents.ClearSelection();</P>
  2. Shawn Krivjansky
    Shawn Krivjansky avatar
    86 posts
    Member since:
    Jan 2010

    Posted 03 May 2011 Link to this post

    Curious about this myself.

    So, my specific question is...  how to get the "loadondemand" combobox back into it's initial state after you have already loaded/selected/used it??  I mean... I want the "empty text" to appear like it wasn't touched before (even though it has been).  I've tried reloading, rebinding, clearing... etc.  Nothing seems to get it back into it's initial state.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 05 May 2011 Link to this post

    Hello,

    When you use RadComboBox with Load-On-Demand enabled you can "reset" the control at server-side by clearing its selection and text:
    <telerik:RadComboBox ID="RadComboBox1" runat="server"
        EmptyMessage=" -Select- "
        OnItemsRequested="RadComboBox1_ItemsRequested"
        EnableLoadOnDemand="true">
    </telerik:RadComboBox>
     <asp:Button ID="btnTest" runat="server"
        Text="Clear selection"
        OnClick="BtnTest_OnClick" />
    protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        this.RadComboBox1.Items.Add(new RadComboBoxItem("item1", "1"));
        this.RadComboBox1.Items.Add(new RadComboBoxItem("item2", "2"));
        this.RadComboBox1.Items.Add(new RadComboBoxItem("item3", "3"));
    }
     
     
    protected void BtnTest_OnClick(object sender, EventArgs e)
    {
        this.RadComboBox1.Text = "";
        this.RadComboBox1.ClearSelection();
     
    }


    All the best,
    Kalina
    the Telerik team

    Browse the vast support resources we have to jump start 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.

  5. Shawn Krivjansky
    Shawn Krivjansky avatar
    86 posts
    Member since:
    Jan 2010

    Posted 05 May 2011 Link to this post

    Thanks for the info.  I hadn't seen this done in any of the examples or documentation before.  Will be a big help.
  6. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 11 May 2011 Link to this post

    Hello Shawn Krivjansky,

    Thank you for the suggestion.
    We will consider adding this info in our online help.

    Regards,
    Kalina
    the Telerik team

    Browse the vast support resources we have to jump start 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.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017