Expressions in DataGrid Columns

Hi,

Just wondering if I'm doing something the best way? In a DataGrid I have a column that I want to populate based on a value in the underlying table. It's a Status Code, which will contain either "O" or "C". I wqant to show this as "Open" or "Closed" in the column.

As it stands, I've had to populate a couple of string variables, isopen and isclosed, then I've added the following code:

       <RadzenDataGridColumn TItem="Customer" Title="Me" Sortable="false">
            <Template Context="data">
                @if(@data.ORG_Status == "O") {@isopen} else {@isclosed}
            </Template>
        </RadzenDataGridColumn>

This works, but I couldn't seem to get it to work by just quoting the required text string, as in

       <RadzenDataGridColumn TItem="Customer" Title="Me" Sortable="false">
            <Template Context="data">
                @if(@data.ORG_Status == "O") {"Open"} else {"Closed"}
            </Template>
        </RadzenDataGridColumn>

Is the way I've done it the best/only way?

Cheers
Reg

Hi @SolutionJ,

There is a simpler solution:

<Template Context="data">
@(data.ORG_Status == "0" ? "Open" : "Closed")
</Template>

Magic, many thanks Korchev...