Friday, May 25, 2012

How to give custom Date format for null type?

Say you have model like below.

Model

public DateTime? date { get; set; }

Then you can use u'r View as below.

View

<%: date.HasValue ? date.Value.ToString("yyyy-MM-dd hh:mm:ss") : "[N/A]"%>

No comments:

Post a Comment

Thanks for your Feedback.