CheckBox showing initial null value with TriState="false"

Hello @Team.

The CheckBox will show the X for the null value if nullableValue is null at first render.

<RadzenCheckBox @bind-Value=@(nullableValue) TriState="false" TValue="bool?"/>


This property controls only if the value can be set to null by the user. The CheckBox component will still show X if null is passed as value.

1 Like

I have this issue as well when it's an "Add" form, the value doesn't exist. Workaround?

Setting the property on form load works, but is cumbersome when you have a ton of checkboxes. Changing the field to not accept null also works in my case.

Yeah, welcome to hell.

You can also set a default value for your DB column. The RadzenCheckBox Value type is Nullable<bool> and its default is null. Unfortunately Blazor does not support conditional generic arguments and we didn't feel asking the user to specify TValue for a checkbox is worth it.

I agree, setting default values is the way to go for most people. We had to remove the default values though, because of the high network traffic between our APIs that this results in. JSON serializers usually have the option to ignore null values, but if they default to false, in this boolean example, the property will needlessly be serialized.