Is there any way to get a formatted value in e.g. a numeric box straight out of the editor? Any attempt I do leads to a message saying it is not supported because of C# and markup mix.

What would be the best way ?

Thank you


Hi @FredK_Trashmail,

Formatting is not supported for Radzen numeric component - just raw value.

Fair enough. Any suggesstion for a datagrid column, apart from standard format string as currency or decimal (e.g. € 32 500) ?

Thank you


At the moment that only option I can offer you is standard format string as currency.

ok. Thanks.
Maybe something to keep in mind.


Looks like my problem is bigger than just formatting.
I have 3 fields in DB: NominalAmount, Volume and UnitPrice, all defined as DECIMAL(5,2)
On NominalAmount Change event, I want to recalculate the UnitPrice as UnitPrice = NominalAmount / Volume. Issue is result is always an integer

What do I do wrong ?



Hello @FredK_Trashmail!

In C# the division operator ('/') returns the quotient of two numbers. If you're dividing a round number, you will get a round number as result. If you want a floating-point quotient, then you must cast the input as float, double, or decimal types. Here are some examples:

5 / 2 = 2
(double)5 / 2 = 2.5
5 / 2.5 = 2

1 Like

Thank you for this Kim.

Yet, all variables are defined as Double in DB and ${opp.UnitPrice} = (double)(opp.NominalAmount / opp.Volume) still returns an integer in the numeric box.

${opp.UnitPrice} = (double)${(opp.NominalAmount / opp.Volume)} brings the same result.

What are the C# types of those properties?

Double, all 3 of them

Tried to reproduce it in the attached application but everything works as expected. Does this app work for you? What is different in your case? (3.9 KB)

The example works, thank you for that.

I changed to Change Event accordingly I think but when I try to push back the value to the record value, it somewhat moves back to integer, even though the field is defined as Double in DB.

I recommend running the application with Visual Studio and debugging the code to see where it changes to integer.

When debugging (screenshots below), I realised it is not a formatting issue but something else. There is an usual behaviour with following sequence:
my UnitPrice property now being set to: ((double)opp.NominalAmount / (double)opp.Volume)

  1. When I start, UnitPrice = 0 because calculation was never saved and NominalAmount is unchanged

  2. I change NominalAmount to 3,000,000, press enter or tab, nothings happens

  3. I change NominalAmount to 3,100,000 and UnitPrice returns 4 (3000000/750000) instead of 4.13333

  4. I change NominalAmount to 3,200,000 and UnitPrice returns 4.13333333 instead of 4.266666

  5. I change NominalAmount to 50,000 and it returns 4.26666666

So it looks like there is an offset and that UnitPrice is updated before.

From a debugging standpoint, I have this:

Value changes adequately

but the new value is not rendered in the numeric box:

There is no UnitPrice being set anywhere else than the NominalAmount ChangeEvent

Can you reproduce this problem in the attached application? It looks that your configuration is different and it uses the old value of the properties.

Attached application works fine (so I guess the component too). Difference is that the initial values are not set as properties but extracted from the table ${result}

Which Change event are you using? You should be using the Numeric's Change event. If you still can't make it work send us your application and SQL script of your database to so we can attempt to reproduce the problem.

i am using the Change Event of the NominalAmount which is Numeric.
Before sending everything over, I will start this part from scratch and come back if required instead of giving you that workload for probably a silly issue.

What debugging shows is that the correct value is calculated at the right time but not propagated to the Numeric Box itself whose value is not UnitPrice but ${opp.UnitPrice}. It kind of relates to something you mentioned in a different thread and that I probably didn't grasp.

The sequence is the following:

  • I am changing NominalValue,
  • we know from the debugging that UnitPrice is calculated properly,
  • I am setting ${opp.UnitPrice} = UnitPrice
  • The Numericbox is updated of not the latest UnitPrice but the one calculated before
    I suspect that there might be 2 instances of ${opp.UnitPrice}, one in DB, one in memory and that the conflict is the outcome of the wrong value at the Numeric Box level.

Maybe the Execute C# ${opp.UnitPrice} = UnitPrice is the problem. Try adding another Execute C# action after it with the following code: StateHasChanged()

This will ensure the Blazor state is refreshed.

Yep, case closed :slight_smile: