I am trying to clear a radcombox previously selected value based on some condition.
but in my code radComboBox.ClearSelection(); is not working and clearing the previously selected result. What can be the best alternative of ClearSelection(); here to clear my radcombobox's previously selected result?
I am afraid that there is not enough environment to test your code. If you use Telerik RadCombobox, you could try to set it as a selection directly after adding an option without clearing the current selection.
RadCombobox can only select one item at a time. If no item is currently selected, then the
Selected property of all items will be False. Setting the Selected property of one item to
True automatically sets the Selected property of all other items in RadComboBox to
False.
//add new Item to RadCombobox
RadComboBoxItem item = new RadComboBoxItem();
item.Text = positionName;
item.Value = positionId;
ddlPosition.Items.Add(item);
//set selected option
RadComboBoxItem item = ddlPosition.FindItemByText(positionName);
item.Selected = true;
And the use of this control is different from ordinary ComboBox. Please refer to
this document for more details.
Hope this can help you.
Best regards,
Xudong Peng
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
12 Points
42 Posts
RadCombobox method ClearSelection is not working in asp.net
Sep 09, 2020 02:35 PM|mazharul007|LINK
I am trying to clear a radcombox previously selected value based on some condition.
but in my code radComboBox.ClearSelection(); is not working and clearing the previously selected result. What can be the best alternative of ClearSelection(); here to clear my radcombobox's previously selected result?
Contributor
2080 Points
664 Posts
Re: RadCombobox method ClearSelection is not working in asp.net
Sep 10, 2020 05:45 AM|XuDong Peng|LINK
Hi mazharul007,
I am afraid that there is not enough environment to test your code. If you use Telerik RadCombobox, you could try to set it as a selection directly after adding an option without clearing the current selection.
RadCombobox can only select one item at a time. If no item is currently selected, then the Selected property of all items will be False. Setting the Selected property of one item to True automatically sets the Selected property of all other items in RadComboBox to False.
And the use of this control is different from ordinary ComboBox. Please refer to this document for more details.
Hope this can help you.
Best regards,
Xudong Peng