Concatenate with IIF leads to error

Stimulsoft Reports.NET discussion
Post Reply
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Concatenate with IIF leads to error

Post by Jennypi »

Hi,

In a text component I am trying to concatenate several fields with IIF conditions:

Code: Select all

{IIF(labels.A==0,"","A ")
+IIF(labels.B==0,"","B ")
+IIF(labels.C==0,"","C ")
+IIF(labels.D==0,"","D ")}
I am getting this error "Operator '+' cannot be applied to operands of type 'object' and 'object'".
I tried to change the operator ("&" or "," which leads to a "no overload" error), to put more brackets, but couldn't find what's wrong.

Could you please help?

Thank you very much.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Concatenate with IIF leads to error

Post by Jan »

Hello,

Try to use following expression:

Code: Select all

{IIF(labels.A==0,"","A ").ToString()
+IIF(labels.B==0,"","B ").ToString()
+IIF(labels.C==0,"","C ").ToString()
+IIF(labels.D==0,"","D ").ToString()}
or

Code: Select all

{labels.A==0 ? "" : "A "
+labels.B==0 ? "" : "B "
+labels.C==0 ? "" : "C "
+labels.D==0 ?"" : "D "}
Thank you.
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Concatenate with IIF leads to error

Post by Jennypi »

First solution works perfectly!

Thanks a lot.
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

Concatenate with IIF leads to error

Post by Andrew »

Hello,

This is very nice.
Have a good day!

Thank you.
Post Reply