I have the below GridCalculatedColumn object and it's being added to the GridTableView but it fails at runtime:
var calculatedColumn = new GridCalculatedColumn
{
DataFields = "Volume",
Expression = "iif({0}=null,'NA',{0}*100)",
DataFormatString = "{0:0.00}%",
};
What is required to be done is that if the "Volume" field is null, it should display "NA" text otherwise it should display the Volume in 0:0.00 format.
How to achieve this with GridCalculatedColumn?
I'm getting this error:
Telerik.Web.UI.ParseException: Neither of the types 'String' and 'Nullable`1' converts to the other.
The data type of {0} i think is Nullable<decimal>.
Another try:
I removed the DataFormatString and put this expression:
iif({0}.HasValue, Convert.ToString({0}.Value), "NA")
and it worked but it just shows data in a different format e.g. it displays as 100.40 rather than 100.40%.
How to apply formatting inside the expression?
I used String.Format() but it gave an error message.
Thanks guys,
var calculatedColumn = new GridCalculatedColumn
{
DataFields = "Volume",
Expression = "iif({0}=null,'NA',{0}*100)",
DataFormatString = "{0:0.00}%",
};
What is required to be done is that if the "Volume" field is null, it should display "NA" text otherwise it should display the Volume in 0:0.00 format.
How to achieve this with GridCalculatedColumn?
I'm getting this error:
Telerik.Web.UI.ParseException: Neither of the types 'String' and 'Nullable`1' converts to the other.
The data type of {0} i think is Nullable<decimal>.
Another try:
I removed the DataFormatString and put this expression:
iif({0}.HasValue, Convert.ToString({0}.Value), "NA")
and it worked but it just shows data in a different format e.g. it displays as 100.40 rather than 100.40%.
How to apply formatting inside the expression?
I used String.Format() but it gave an error message.
Thanks guys,