Clearing a selected DropDown item without bind-Value

1.2k Views Asked by At

How can we clear/reset the selected item on a Radzen DropDown?

I did not use bind-Value to get the selected item.

Instead, I used Change() to get the selected object.

However, if I select one item on the DropDown and change the content of tempLocations, the selected item itself will not be cleared.

View:

<RadzenDropDown Name="Location" TValue="string" Data=@tempLocations Change=@(args => LocationChange(args))>
        <Template Context = "location">
            @($"{location.id}:{location.name}")   
        </Template>
    </RadzenDropDown>
1

There are 1 best solutions below

0
On BEST ANSWER

I guess there will be no solution expect using bind-Value.
Here is my updated coding:

<RadzenDropDown @bind-Value=@tempSelectedLocation Name="ALocation" Data=@tempLocations Change=@(args => LocationChange(args))>
                <Template Context = "location">
                    @($"{location.pressure} {location.name}")  
                </Template>
            </RadzenDropDown>

tempSelectedLocation is a class object.