0

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?

Popo
  • 2,402
  • 5
  • 33
  • 55
  • possible duplicate of [Is there a conditional ternary operator in VB.NET?](http://stackoverflow.com/questions/576431/is-there-a-conditional-ternary-operator-in-vb-net) – Iłya Bursov Oct 18 '13 at 22:40
  • @IlyaBursov I know there is a ternary operator, my question has to do with why am I getting an error in my data binding. – Popo Oct 18 '13 at 22:44
  • Do you use VB.NET 2008? `maybe Container.DataItem.rDate.isEmpty = TRUE` will help – Iłya Bursov Oct 18 '13 at 22:50

1 Answers1

0

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

Popo
  • 2,402
  • 5
  • 33
  • 55