Thursday, 15 July 2010

c# - Eval can't access a nullable DateTime? -


Usually, on a foreach inside .ascx, I use a tap with the time of the correct date:

  & lt;% = item.DataModifica.Value.ToShortDateString ()%>   

But if I tried it on a repeater:

  & lt;% # Eval ("DataModifica.Value.ToShortDateString ()"). ToString ()% & gt;   

I get an exception

There is no property with name in System.DateTime 'value'

Where am I wrong?

I recommend that you change the code like this:

 < Code> & lt;% # convert ToDateTime (Eval ("DataModifica")). ToShortDateString ()% & gt;    

No comments:

Post a Comment