Correct way of binding data

Hi,

When I create a page using the "Master/Detail" page template, I can see in the "RowSelected" event of the first grid, that a page variable "master" is assigned with the selected record from the grid.

How can I display data from that record on the current screen, e.g. in a text box? If I bind the "value" of the control to ${master?.MyProp} I get "The left-hand side of an assignment must be a variable, a property or an indexer". When I try "@master?.MyProp" it seems to work but only for first level properties.

E.g. I have a server-side calcuclated property (used this approach: Calculated fields on the server side - Radzen ) that I cannot bind using this syntax because it gives me an error that my DB context is gone once the getter is invoked. - In my getter of that calculated property I use a Linq expression...

So how can I bind to a field using the "${master?.MyProp}" syntax to retrieve the value of that calculated field? The data should be there since the grid has loaded the data and the even assigned the record to the page variable.

Thanks for your help!

You can't use two-way data-binding with ?. syntax which is a Blazor limitation. We can suggest you to create a helper page property which is set to `${master?.MyProp} and use that property for display.

Thanks a lot! That works. However, I think I found a bug when trying your approach:

Create a page variable of type "DateTime?" in OnLoad of the page and assign it to the inital value of null.

Then somewhere else (in my case in the OnRowSelect handler), add a new action and select "Set Property" and select the previously created variable from the dropdown.

I added this value: ${master.SomeDateField}

Now, the data type is derrived as "System.DateTime?". This leads to an error when you compile telling you that your page variable already exists. And in fact, the declaration of the property appears twice in the generated .cs file.

The problem is that data type "System.DateTime?". If I change it to "DateTime?" the duplicate declaration in the code is gone and everything works. So I assume that your code generator thinks that DateTime? and System.DateTime? is not the same...

Anyway, thanks again for your excellent support! :slight_smile: