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
Post a Comment