Pages

Sunday, May 25, 2014

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 ur View as below.

View

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

Related Posts by Categories

0 comments:

Post a Comment