Multiple selection RadzenDropDownDataGrid clear button sets binded value to null instead of empty #908

Closed
opened 2026-01-29 17:46:09 +00:00 by claunia · 2 comments
Owner

Originally created by @AfzalSohaib on GitHub (Jul 3, 2023).

Describe the bug
RadzenDropDownDataGrid with AllowClear="true" and Multiple="true" will set the bound variable to null instead of empty. This causes runtime errors if the bound variable is not nullable.

To Reproduce
Steps to reproduce the behavior:

  1. Using dotnet 6, browser Firefox
  2. Define the component with auto-clear and multiple selection
  3. Use @bind-Value="values" where values is IEnumerable<int>
  4. Add some values to the dropdown, then click the "clear" cross button

Expected behavior
The clear button should set "values" to be an empty IEnumerable<int>

Desktop (please complete the following information):

  • OS: Ubuntu 22.04 LTS
  • Browser Firefox
  • Version 114.0.2 64 bit

Additional context
If we define values as IEnumerable<int>? i.e. a nullable enumerable then problem does not occur.

Originally created by @AfzalSohaib on GitHub (Jul 3, 2023). **Describe the bug** RadzenDropDownDataGrid with AllowClear="true" and Multiple="true" will set the bound variable to null instead of empty. This causes runtime errors if the bound variable is not nullable. **To Reproduce** Steps to reproduce the behavior: 1. Using dotnet 6, browser Firefox 2. Define the component with auto-clear and multiple selection 3. Use `@bind-Value="values"` where values is `IEnumerable<int>` 4. Add some values to the dropdown, then click the "clear" cross button **Expected behavior** The clear button should set "values" to be an empty `IEnumerable<int>` **Desktop (please complete the following information):** - OS: Ubuntu 22.04 LTS - Browser Firefox - Version 114.0.2 64 bit **Additional context** If we define values as `IEnumerable<int>?` i.e. a nullable enumerable then problem does not occur.
Author
Owner

@enchev commented on GitHub (Jul 6, 2023):

Hey @AfzalSohaib,

There is nothing wrong to set IEnumerable<int> to null:
image

Most probably you have exceptions somewhere in your code.

@enchev commented on GitHub (Jul 6, 2023): Hey @AfzalSohaib, There is nothing wrong to set `IEnumerable<int>` to null: ![image](https://github.com/radzenhq/radzen-blazor/assets/5804953/b606adea-ec42-47ca-a31c-2ce246b96697) Most probably you have exceptions somewhere in your code.
Author
Owner

@AfzalSohaib commented on GitHub (Jul 8, 2023):

In dotnet 6 and later, nullable reference types are enabled which throws exceptions when setting reference types to null unless they are explicitly market as nullable i.e. IEnumerable<int>?

@AfzalSohaib commented on GitHub (Jul 8, 2023): In dotnet 6 and later, [nullable reference types](https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references) are enabled which throws exceptions when setting reference types to null unless they are explicitly market as nullable i.e. `IEnumerable<int>?`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#908