DropDown not clearing selection when setting @bind-Value property to null

When setting the binded property to null, the DropDown selections are not being cleared.
I'm displaying the binded property on the page, to show that the property itself is clearing.

Untitled_ Jun 21, 2022 10_41 AM

<div class="col-md-6 ol-lg-4 col-xl-3 p-3">
    <RadzenButton Text="Reset" Click="@Reset" />
    <br />
    @if (selectedGroups != null && selectedGroups.Any())
    {
        @foreach (var item in selectedGroups)
        {
            <span>@item</span>
            <br />
        }
    }
     <RadzenCard>
        <h4 class="mb-4">Multiple selection</h4>
        <RadzenDropDown AllowClear="true" AllowFiltering="true" @bind-Value=@selectedGroups Multiple="true" Placeholder="Select..."
                        Data=@groups TextProperty="GroupName" ValueProperty="GroupId" Style="width: 250px;" />
    </RadzenCard>

</div>

@code {
    private IEnumerable<GroupSetting> groups = new List<GroupSetting>();
    private IEnumerable<string> selectedGroups = new List<string>();

    protected override async Task OnInitializedAsync()
    {
        groups = await GroupSettingRepository.GetAllAsync();
    }

    private async Task Reset()
    {
        selectedGroups = null;
    }
}

Hi @nitrouscookies,

You can clear the value by setting selectedGroups to new List<string>().

1 Like