I have an SPGridView with a list as its source. I currently have it sorting first by published date, or if that is null, by modified date. The problem is that on the list view I need to put Posted on DD/MM/YY at HH:MM in each row. I came up with this monsterous evaluation (which is all on one line in the markup):

Posted on
  <%# Eval("PublishedDate") == null ? 

Convert.ToDateTime(Eval("Modified")).ToShortDateString()    
  + "at" + Convert.ToDateTime(Eval("Modified")).ToShortTimeString()   

: Convert.ToDateTime(Eval("PublishedDate")).ToShortDateString() + " at " + 
Convert.ToDateTime(Eval("PublishedDate")).ToShortTimeString()%> 

Anyway, It doesn't work. If I remove the ternary operator and just go with one option, it works. While googling about this I saw that it is perfectly valid to use the ternary inside of <%# %>. What am I doing wrong?

link|improve this question
when you say it doesn't work, what happens...error?...always evaluates to true?...always evaluates to false? – Rob D'Oria Aug 20 '11 at 14:35
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.