SfGrid dialog edit SfCheckBox int value int error

Hello, I am using SfCheckBox in SfGrid dalog mode, bind-value int so I get an error, how can I solve this, there is sample code below.

Thank you in advance


<div class="form-group col-md-3">

    <label for="@stock. passive">Passive</label>

    <SfCheckBox ID="Pasiv" @bind-Checked="@stock.passive" TChecked="int" >

    </SfCheckBox>

</div>






1 Reply

YA YuvanShankar Arunagiri Syncfusion Team December 2, 2024 06:10 AM UTC

Hi Ahmet,


We have checked your reported query, and for more clarification, the Checkbox component TChecked property supports only the bool type. Currently we don’t have support to set the int type to the TChecked property of the checkbox component. For now, we can handle the checkbox component checked property with an int type value. Refer to the below code snippet.


<div class="form-group col-md-3">

    <label>Passive</label>

    <SfCheckBox Checked="@(passive == 1 ? true : false)" TChecked="bool" ValueChange="OnChange"></SfCheckBox>

</div>

 

@code{

    private int passive = 1;

    private void OnChange(ChangeEventArgs<bool> args)

    {

        passive = args.Checked == true ? 1 : 0;

    }

}


Based on passive integer value (0 or 1), we can set the checked property of checkbox component and same time, we can update the integer value using the ValueChange event of checkbox component like above code snippet.


Kindly get back to us if you need any further assistance on this.


Regards,

YuvanShankar A


Loader.
Up arrow icon