I need to set a Field with a decimal? value, if doesn’t have value it should show the "-".
I tried use this code:
Field="@(nameof(this.DataDTO.EventDefaultValue > 0 ? this.DataDTO.EventDefaultValue.ToString("F2") : "-"))"/>
But doesn’t is possible convert, the Visual Studio show the error
I’m using the Blazor, together with DevExpress DxDataGridColumn component.
How can I to resolve this point? Someone can help me?
2
Answers
As it is the comment above the use of
nameof()
was wrong. I removed thenameof()
and usedDisplayTemplate
component to set a field in my grid and pass a data of context.As I needed to make a condition verification the
DisplayTemplate
was a good solution.The code was this below:
And this result was this below:
nameof()
method is used to get the name of a method, or a class for example. But you use it with some logic inside, so it will hit an error.The parameter
Field
is generally use – for example in the Telerik Library’s components – to target a field of a class. I am pretty sure it is exactly the same here, you wanna give the name of the field of your class that the column you set is reffered to. For exampleField="@nameof(DataDTO.EventDefaultValue)
will tell to Blazor "this column will display the EventDefaultValue field of the object".