Two things:

  1. Casting to double shouldn't be needed as all properties are of type double.
  2. You can merge both actions into one Execute C# action (unless you need UnitPrice for something else):

${opp.UnitPrice} = opp.NominalAmount / opp.Volume; StateHasChanged();

1 Like

Was merging as I received your mail :slight_smile:

On the Double issue, removing them doesn't work and I am back with the Int value. I can only guess that ${opp.NominalAmount} and ${opp.Volume} are Doubles but opp.NominalAmount and opp.Volume aren't.

Anyway, that works now

Thank you.

Maybe it is coming from Numeric3Change(int? args)

ah ah. This is driving me crazy.

If I do a similar calculation for the Volume Change event, I get an error

but this works:

This means that the inferred type for those textboxe components is not correct for some reason. Try adding them again. Or add a custom attribute with name TValue and Value double

Also don't cast to (int?) this makes things even worse.

Will look at textboxes.
As my coding experience doesn't go beyond my Radzen exp, not sure I understand how TValue works and what will it do in this case

The type casts you have added have changed something vital for the Numeric components. I suggest removing the problematic component and adding it again.

Last but not least - why are you doing this to begin with? Why is UnitPrice both calculated and editable? Your users will find it very strange that UnitPrice changes after they have manually entered it (after changing NominalAmount or Volume). IMHO you should do one of the following to provide a lot better user experience:

  • Set initial value for UnitPrice and don't update it whenever NominalAmount or Volume changes
  • Leave UnitPrice to be entered by the user freely
  • Hide UnitPrice altogether - update it whenever NominalAmount or Volume changes but don't allow the user to edit it in a TextBox

Doesn't work.
Nor TValue.

From a business perspective, when the sales exec is answering a Request For Proposal, he gets a margin (haven't brought that into the mix yet ) from the production plant. He will then work out the unit price so that there is an additional margin for negotiation and possibly change it as part of the final negotiation. Buyers in this industry agree on unit price and Volume but also may slightly adjust the volumes in the last round. The Sales Exec may also try to see what would be the Unit Price (and associated margin) if the overall deal would be at a certain overall amount.
To make it short, all 4 (margin being the last to incorporate) need to be actionnable.

Just realised that Volume and NominalAmount could be Int. Would that make things easier knowing that UnitPrice can only be Double ?

What doesn't work? I have attached a working example.

This would be horrible UI for your users and lead to unexpected changes in UnitPrice.

Anyway - remove all Numeric components, add them one by one and set each Value property before adding a Change event handler.

What I mean is I did it to no avail.

Will try again.

With TValue / Double ?

Honestly I no longer understand what you have done. First you said it was working, then you added unnecessary casts to int? (not sure why) and things broke. Please send us your application to so we can fix.

It was working for updating the UnitPrice upon a NominalAmount Change but not when doing a similar things for Volume.

Now removed everything. Moved back fields to Double (tried Int previously but there was no way it could work).

and it works smoothly with standard Property definition.

On your point about ugly UI, if fields are editable or not, it does not change much. Some industries have their own way of doing things because every client wants something different and unique which requires specific implementations of custom machinery at the plant level and the sales process particular. Take a look at the subtle difference between a water bottle cap and another. Never the same from a brand to the next.

Anyway, thank you for the assistance