asp.net mvc - In ModelState the Date format is not valid while editing Kedno grid -
i developing mvc application kedno grid. have model item properties:
public bool ispaid { get; set; } public nullable<datetime> paymentdate { get; set; }
in kedno grid in view:
columns.bound(c => c.paymentdate).format("{0:dd-mmm-yyyy}");
when editing in grid , set ispaid false logic has setting paymentdate null.
for example have item paymentdate 22-sep-2016 , ispaid true
.
after editing in kendo grid item setting ispaid false, , when click save changes, invoked method update in controller:
public actionresult update([datasourcerequest] datasourcerequest request, [bind(prefix = "models")]ienumerable<itemviewmodel> items) { if (modelstate.isvalid) { // } }
but modelstate not valid: "the value '9/22/2016 12:00:00 am' not valid for...".
if paymentdate 01-sep-2016, modelstate valid.
also, followed steps in globalization section.
in web.config:
<globalization uiculture="bg-bg" culture="bg-bg"></globalization>
in controller:
protected override void initialize(requestcontext requestcontext) { thread.currentthread.currentculture = thread.currentthread.currentuiculture = new cultureinfo(requestcontext.httpcontext.request.userlanguages[0]); base.initialize(requestcontext); }
in view:
@{ var culture = system.globalization.cultureinfo.currentculture.tostring(); } <script src="@url.content("~/scripts/cultures/kendo.culture." + culture + ".min.js")"></script> <script> kendo.culture("@culture"); </script>
any suggestions?
thanks lot!
Comments
Post a Comment