Data binding with a string value using a Checkbox







@String.Format("{0:d}", data.alg_anlagedat)


        <RadzenGridColumn TItem="Ams_alg" Property="alg_aenderdat" Title="Änderung am">
            <Template Context="data">
                @String.Format("{0:d}", data.alg_anlagedat)
            </Template>
        </RadzenGridColumn>
        <RadzenGridColumn TItem="Ams_alg" Property="alg_aenderuser" Title="Änderung von" />
        <RadzenGridColumn TItem="Ams_alg" Property="alg_kontenplan" Title="Kontenplan">
            <Template Context="data">

                @if (data.alg_kontenplan == "J")
                {
                    <RadzenCheckBox Value="true"
                                    TValue="bool"
                                    Change="@( (args => { ItemChanged(args,data.alg_kontenplan); }))">
                    </RadzenCheckBox>
                }
                else
                {
                    <RadzenCheckBox Value="false"
                                    TValue="bool"
                                    Change="@( (args => { ItemChanged(args,data.alg_kontenplan); }))">
                    </RadzenCheckBox>
                }

            </Template>
        </RadzenGridColumn>
    </Columns>
</RadzenGrid>

The Code above is as far as i get. It displays correctly but i dont know how to update the acutal value
in the class. Problem is that the column is actual a string in the database and in the parents class
representing J = Yes for true and N=No for false. What is the best way to bind it ? Do i really have to write a function for it?
Any help would be highly appreciated!

Hi @whann,

The RadzenCheckBox supports only boolean properties. You will need some extra code in the Change event to convert the value to "J" or "N" strings. Something like

Change="@(checked => { data.alg_kontenplan = checked ? "J" : "N"; } )

That was exactly the solution i was looking for. THANK YOU!!!!!
Only problem was that the property is with a captial C eg. Checked not checked

Change="@(Checked => { data.alg_kontenplan = Checked ? "J" : "N"; } )