Search code examples
vb.netdata-bindingrepeater

If statement inside data binding for repeater


I am trying to perform a ternary if statement inside my databinding for a repeater:

<%# If(Container.DataItem.rDate.isEmpty, String.Empty, Format(Container.DataItem.rDate.Date, "Short Date"))%>

This should be the equivalent to:

If rDate.isEmpty then
    String.Empty
Else
    String.Format(rDate, "Short Date")
End If

However, I get a compilation error at runtime: Expression expected @

<%# If(Container.DataItem.rDate.isEmpty, String.Empty, Format(Container.DataItem.rDate.Date, "Short Date"))%>

Any Ideas as to what is wrong here?


Solution

  • Turns out that at runtime, IIS was using an older version of VB.Net so I had to use IIF, instead of If