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

Resetting a RadComboBox...

4 Answers 432 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
mark baer
Top achievements
Rank 1
mark baer asked on 02 May 2011, 06:01 PM
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>

4 Answers, 1 is accepted

Sort by
0
Shawn Krivjansky
Top achievements
Rank 1
answered on 03 May 2011, 06:24 AM
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.
0
Kalina
Telerik team
answered on 05 May 2011, 05:32 PM
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.

0
Shawn Krivjansky
Top achievements
Rank 1
answered on 05 May 2011, 05:46 PM
Thanks for the info.  I hadn't seen this done in any of the examples or documentation before.  Will be a big help.
0
Kalina
Telerik team
answered on 11 May 2011, 09:32 AM
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.

Tags
ComboBox
Asked by
mark baer
Top achievements
Rank 1
Answers by
Shawn Krivjansky
Top achievements
Rank 1
Kalina
Telerik team
Share this question
or