IIf and expressions

edited 10:20AM in FastReport .NET
I like to print a conditional to a parameter. I entered an expression as follows:

[IIf([newpage_groepveld]=="1" , [Table.afroepregels_refentie] , [Table.afroepregels_plantnaam])]

Because IIf is a VB syntax I tried the C# syntax also:
[newpage_groepveld]=="1" ? [Table.afroepregels_refentie] : [Table.afroepregels_plantnaam];

Both do not work.

How can I conditional print the one or the other field?

Tia
Hans

Comments

  • edited 10:20AM
    Hello,

    Both
    [IIf([newpage_groepveld]=="1" , [Table.afroepregels_refentie] , [Table.afroepregels_plantnaam])]
    and
    newpage_groepveld]=="1" ? [Table.afroepregels_refentie] : [Table.afroepregels_plantnaam
    must work. The "newpage_groepveld" report parameter must be of String type. If it is numeric, use ... == 1 instead of ... == "1".
  • edited 10:20AM
    I used this expression at the GroupHeader Band Condition. Here this results in an error CS1525 followed by CS1002.

    Is this caused because we using an expression with a "IIf"in a group header?
    BTW, we can use expression like [Table.col1] + [Table.col2], it only fails when we add the "IIf" construction.

  • edited 10:20AM
    In this case you don't need outer brackets:
    IIf([newpage_groepveld]=="1" , [Table.afroepregels_refentie] , [Table.afroepregels_plantnaam])
    (they are needed if you print this in the Text object).

Leave a Comment