c# - format datetime object inside ajax.actionlink -


i have view there ajax.actionlinks, of these action links need display date property of model , have date property follows:

[display(name = "date")] [datatype(datatype.date)] [displayformat(dataformatstring = "{0:mm-dd-yyyy}", applyformatineditmode = true)]  public datetime? date { get; set; } 

however, because ajax.actionlink accepts string first argument, can't use lambda expression :

m => m.date 

rather i'm using

model.date.tostring() 

but isn't showing formatting want. i've tried doing

model.date.tostring("mm-dd-yyyy"); 

but i'm getting red underline because not recognizing tostring overload 1 argument... ideas on how can work?

since model.date nullable, need access value of datetime? before using version of tostring:

model.date.hasvalue ? model.date.value.tostring("mm-dd-yyyy") : null; 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -