IIf is not working with IsNull
I'm trying to make this expression work (in a textbox) with no success:
[IIf(IsNull(fieldA), fieldB, fieldA)]
I set fieldA = null and I expect that fieldB is printed, according to the expression, but fieldA is what is being printed.
Can you help me ?
Comments
The problem was reproduced. I will inform programmers about it. As a workaround, you can create your own function and use it.
In the script:
bool MyIsNull(object n)
{
if (n == null)
return true;
else
return false;
}
In the designer:
[IIf(MyIsNull([fieldA]), [fieldB], [fieldA])]
Thank you, Anatoly. It works.
Amazed years later this still has not been fixed!
The suggested workaround could be simplified to:
bool MyIsNull(object n)
{
return n == null;
}
If the C# script version were updated to newer, it could even just be:
bool MyIsNull(object n) => n == null;
Where do you put the script in please? I am new to FastReports.