Multiple checkbox binding

How do I make checked only checkbox I clicked and not checking all checkboxes?

@foreach (var principle in Principles)
{

                        var principleId = @principle.PrincipleId;

                    <tr>

                        <td>@principle.Description</td>
                        <td><RadzenCheckBox id="@principle.PrincipleId"  TValue="bool"  bind-Value="CheckboxValue"   Change="@(args => ChangePrincipleCheckbox(args,principleId))"  /></td> 
                        

                    </tr>
                    }

@code {
void ChangePrincipleCheckbox(bool value, int principleId)
{

    CheckboxValue = value;

}
}

maybe this is simpler question. Why without change function I see checkbox changing but with change function checkbox visually is not changing. Maybe a bug?

@RadzenCheckBox id="@principle.PrincipleId" TValue="bool" Value="false" /> - works I see visually checkbox changes

@RadzenCheckBox id="@principle.PrincipleId" TValue="bool" Value="false" Change="@(args => ChangePrincipleCheckbox(args,principleId))" /> - i do not see visual checkbox change

Hi @chebyr,

What does the ChangePrincipleCheckbox method do? If it somehow causes StateHasChanged you are hitting this Blazor bug/limitation. You will need to use @bind-Value as well.

Hi if I i have 16 checkboxes generated by for loop then binding will check/uncheck all 16 checkboxes and I need to check /uncheck then one I clicked. I guess because bind-Value="CheckboxValue" applies to all of them. Is there a way to bind to specific checkbox I am working with?

The method does some logic but nothing with ui .

Thank you,

In this case you could try with an array of equal size:

@bind-Value="CheckboxValue[i]"

Brilliant that worked! thank you a bunch

Hey can you please tell me how to edit multiple checkbox values
for create i use

this code
but when i use it for edit System.NullReferenceException: 'Object reference not set to an instance of an object.' CrudWith Radzen.ViewModel.Product ViewModel.Features List.get returned null.this type of error was shown

Hey @Kuljeet_Kaur,

You can check what’s null when you debug your application with Visual Studio.