forum

Home / DeveloperSection / Forums / @Html.DisplayFor - DateFormat (“mm/dd/yyyy”)

@Html.DisplayFor - DateFormat (“mm/dd/yyyy”)

Anonymous User 14883 15-Apr-2015

I have the following razor code that I want to have mm/dd/yyyy date format: 

Audit Date: @Html.DisplayFor(Model => Model.AuditDate)

I have tried number of different approaches but none of that approaches works in my situation 

my AuditDate is a DateTime? type 

I have tried something like this and got this error: 

@Html.DisplayFor(Model => Model.AuditDate.Value.ToShortDateString())

Additional information: Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions. 

Tried this: 

@Html.DisplayFor(Model => Model.AuditDate.ToString("mm/dd/yyyy"))

No overload for method 'ToString' takes 1 arguments


.net c# 
Updated on 15-Apr-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By