Support of Google.Protobuf.WellKnownTypes.Timestamp class in Grid and Column


I have a list of objects that have a member of type Google.Protobuf.WellKnownTypes.Timestamp and I want to display it in a Grid. Here is an excerpt of the class:

class VisitModel {
public Google.Protobuf.WellKnownTypes.Timestamp Executiondatetime;

I am trying to display it in a grid like this: (I have removed the HTML <> signs)

RadzenGridColumn TItem="VisitModel" Property="Executiondatetime" Title="Executed On" Width="10px"
Template Context="visit"
@if (visit.Executiondatetime == null)
new String("");
new String(String.Format("{0:MM/dd/yyyy h:mm:ss tt}", visit.Executiondatetime.ToDateTimeOffset().LocalDateTime));

I understand that I must use a template but even if the Executiondatetime is not null, there is nothing displayed in the cell. It is important to mention that IF is not null and the template definition is like this below, it works fine...

@String.Format("{0:MM/dd/yyyy h:mm:ss tt}", visit.Executiondatetime .ToDateTimeOffset().LocalDateTime)

Any advice?


Well, after playing some more and looking at other example here, it seems that his code below works inside the Template definition

[at]if (visit.Executiondatetime == null)
[at]String.Format("{0:MM/dd/yyyy h:mm:ss tt}", visit.Executiondatetime.ToDateTimeOffset().LocalDateTime)

It seams that for every C# line, we need to put the [at] symbol. How is that?

Could not use the real symbol since the editor was giving me an error...

Hi @slamarre,

This is just how Blazor works. You use @ to output properties and expressions. More info about the Razor syntax is available here.