Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Ifcompare with boolean data type View modes: 
User avatar
Member
Member
pete_s - 10/12/2011 3:44:33 AM
   
Ifcompare with boolean data type
Hi,

If I use the following in a transformation:

<%# IfCompare(Eval("Testfield"),0,"No","Yes") %>

And testfield is a boolean datatype, what should I be putting in the comparison field? I've tried 0,-1, 1, etc but nothing seems to work.

Thanks,

Pete

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/12/2011 4:04:19 AM
   
RE:Ifcompare with boolean data type
Hi,

if the field is defined as a checkbox, the default value is empty and if checked the value is true, you can use following code:

<%# IfCompare(CMS.GlobalHelper.ValidationHelper.GetBoolean(Eval("boleanField"), false), true, "false result", "true result")%>

Best regards,
Ivana Tomanickova


User avatar
Member
Member
pete_s - 10/12/2011 5:42:34 AM
   
RE:Ifcompare with boolean data type
Worked a treat, many thanks!

Pete