DateTimePickerFor not picking up Model data

So, in my view I'm running the following line:

@Html.EJ().DateTimePickerFor(model => model.outage_start)

However it defaults to today's date no matter what I try. 

I know that the data is fine because if I use a standard editorfor it works fine:

 @Html.EditorFor(model => model.outage_start)

Any reason why this isn't working? 

Ultimately I'd like to have a datetimepicker that worked something like this:

@Html.EJ().DateTimePickerFor(model => model.outage_start).MinDateTime(Model.outage_start.ToString()).MaxDateTime(Model.outage_end.ToString())

Thanks!

2 Replies

MR Marcos Romero February 11, 2015 11:23 PM UTC

I solved this by explicitly stating the datetime format. So that it has to be MM/dd/yyy hh:mm tt

That worked. Not very user friendly and in fact your example doesn't even work as the min start time does not have a space before the AM. / Thank goodness as this led me to finding a resolution. 

@Html.EJ().DateTimePicker("DateTime").MinDateTime("05/23/2014 09:00AM").MaxDateTime("05/29/2014 09:00 PM").Interval(30)

Should be:
@Html.EJ().DateTimePicker("DateTime").MinDateTime("05/23/2014 09:00 AM").MaxDateTime("05/29/2014 09:00 PM").Interval(30)

My full statement in case anyone else runs into this problem is:
@Html.EJ().DateTimePickerFor(model => model.outage_start).Width("300").MinDateTime(Model.outage_start.Value.ToString("MM/dd/yyyy hh:mm tt")).MaxDateTime(Model.outage_end.Value.ToString("MM/dd/yyyy hh:mm tt")).Value(Model.outage_start.Value.ToString("MM/dd/yyyy hh:mm tt")).Interval(1)


KS Kaliswaran Shanmuga Sundaram Syncfusion Team February 13, 2015 06:46 AM UTC

Hi Marcos,

 

We have logged a task to achieve your requirement. A support incident to track the status of this requirement has been created under your account. Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents  

Please let me know if you have any questions.

Regards,

Kaliswaran S


Loader.
Up arrow icon