DropDown - Clear selected items in code?

Is there a way of clearing the selected items in a dropdown through code?

I have tried setting all variables to null and reloading as recommended in another thread, but can't seem to clear the selections. Thanks for any advice.

My dropdown is setup with this code:

IEnumerable<string> ieLevel = new string[] { "Level" };
IEnumerable<string> evLogLevels;
evLogLevels = GetDropDownStrings("Level"); //<-- Returns list of readable dropdown selections

<RadzenDropDown Placeholder="Selects Level ..." @bind-Value="ieLevel" 
                Data="@evLogLevels" Change="@(args => GetFilters(args, "Level"))"
                AllowClear="false" AllowFiltering="false" Multiple="true"
                Style="height: 30px; width: 150px; margin-bottom: 0px; margin-top: 10px;  margin-left: 0px" />

If the DropDown Value is two-way bound to a property (@bind-Value="SomeProperty") you can simply set this property value to null.

Hi And thank you for the response.

I did try that and that did nothing. I am may not be using the control correctly? While both bound and data are being set, only data is actually being used. The control requires an @bind-Value or it errors. So nothing is done with that value.

Hi @Odavis

It seem that I misunderstood your question. You can use Reset() method to clear selected items.

1 Like

THANK YOU! @enchev, I did not think to use a reference and see what was available. That worked perfectly.

for dropdowns where Multiple=false, settings the value to null will work
for dropdowns where Multiple=true; setting the value to null will NOT work, you will need .Resert()