Radnumeric, nullable value

Can the numeric field hold null values ?
I have autogenerated CRUD pages for a table with nullable int or double values.
The enity is properly generated, the C# types are int? or double?.

Hwoever at run time I get exceptions, saying that the Form function cannot convert null to int or double.
If I specify "0" as Value in the numeric box setup, then it is fine, and the form renders properly.

How can I handle nullable numeric values ?

Thx

Thanks for the report @Stef42! We will release fix tomorrow.

Was this ever fixed? I am using the latest Radzen 2.62.4 and an exception still occurs in the Numeric component if the corresponding DB value is NULL.

Hey @jeremygerbil,

The issue reported in this thread is fixed two years ago. What is the exception you are getting?

Perhaps I'd better explain what I am trying to do and you can tell me a better way:
I have a dropdown that has Data mapped to an EF table result property created on page load i.e GetMytableResult, and the Value is the primary key "ID" (an int). The table Mytable has another (nullable) int column called Sequence.
When a value is selected from the dropdown, I want an adjacent Numeric component to display the value of another column from the selected record.
So in the Change event of the dropdown, I:

  • set an int page property, selectedID, to: ${event} [not sure why this isn't event.Value but that doesn't work]
  • set a page property, selectedRecord to: ${getMytableResult.Where(o => o.ID == selectedID)}

The Numeric component Value is then bound to ${selectedRecord.Sequence} (an int).
At run time I see an object reference undefined exception. However while typing ths out I have realised it is because the selectedRecord page property was initialized to null (${}) on page load so the Value expression causes an exception on rendering. I initialised the property to getMytableResult.First() instead and the error went away, so problem solved.

I would still be interested in any comments as to whether my design is best for this scenario.

Well, the way explained seems that the exception was in your code not in RadzenNumeric component. Indeed if you use nullable variables you will need to check if the value is null before use it.

And would that be done using an expression of the form

${<variable> ?? <defaultvalue>}

?