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

RadComboBox ClearSelection

1 Answer 318 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 25 Apr 2013, 12:12 PM
I know there are a number of threads with this issue, I just wanted to post my specific implementation and see if there is a solution to the corner I seem to be in.

Here is my combobox declaration:
<telerik:RadComboBox runat="server" ID="rcbAssetAssoc" ZIndex="100100" Enabled="false" AllowCustomText="false" MarkFirstMatch="true" Width="100%" Height="190px" EnableLoadOnDemand="true" HighlightTemplatedItems="true" OnItemDataBound="rcbAssetAssoc_ItemDataBound">
<HeaderTemplate>
<ul>
<li class="multiColBoxItem">Serial #</li>
<li class="multiColBoxItem">Asset #</li>
<li class="multiColBoxItem">Machine Name</li>
</ul>
</HeaderTemplate>
<ItemTemplate>
<ul>
<li class="multiColBoxItem"><%# Eval("SerialNumber") %></li>
<li class="multiColBoxItem"><%# Eval("AssetNumber") %></li>
<li class="multiColBoxItem"><%# Eval("MachineName") %></li>
</ul>
</ItemTemplate>
<FooterTemplate>
<asp:Panel runat="server" CssClass="multiColBoxFooter">
<asp:Label runat="server" ID="lblAssetAssocCount" SkinID="atBlueForm" />
</asp:Panel>
</FooterTemplate>
</telerik:RadComboBox>

I have read the solution to clear the selection as:

rcbAssetAssoc.Text = "";
rcbAssetAssoc.ClearSelection();

and that if the combobox is read-only the AllowCustomText="true" must be set to enable the clear to work.

However, if I set the AllowCustomText="true" that creates a bug in my code because I don't want the user typing in their own values.

Am I missing something?

At the end of the day I want a templated dropdown that forces the user to select one of the options with auto-complete style functionality AND have the box clear ready for the next selection.

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 30 Apr 2013, 09:59 AM
Hello Brian,

 
One possible solution that worked properly at my side was adding a default item and using the ClearSelection after that as in the code below:

<DefaultItem Text="" Value="-1"/>
             <HeaderTemplate>
protected void RadButton1_Click(object sender, EventArgs e)
   {
        
       rcbAssetAssoc.ClearSelection();
   }

Hope this will be helpful.

Kind regards,
Plamen
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.
Tags
ComboBox
Asked by
Frank
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or