Page 1 of 1

Concatenate with IIF leads to error

Posted: Mon Oct 18, 2010 4:56 am
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.

Concatenate with IIF leads to error

Posted: Mon Oct 18, 2010 8:34 am
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.

Concatenate with IIF leads to error

Posted: Mon Oct 18, 2010 9:29 am
by Jennypi
First solution works perfectly!

Thanks a lot.

Concatenate with IIF leads to error

Posted: Mon Oct 18, 2010 10:10 am
by Andrew
Hello,

This is very nice.
Have a good day!

Thank you.