This is a migrated thread and some comments may be shown as answers.

Help: DatePicker display incorrect value on selecting new date

2 Answers 198 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 25 Oct 2012, 01:26 AM
i have inline editing grid with datepicker. This is working fine if i use local database(PC database) but not working if i use remote database


shared/editortemplate/DateTime.cshtml

@model DateTime?


@(Html.Kendo().DatePickerFor(m => m).Format("M/dd/yyyy"))



View:
columns.Bound(p => p.DateCompleted).Format("{0:d}").Width(80)       

Model:
 [UIHint("Date")]
 [DisplayName("Date Completed")]
 public DateTime? DateCompleted { get; set; }
when i tried to update and pick another date the tried to save, the date value become null and it weird is only happen if i connect via remote database



please advise

2 Answers, 1 is accepted

Sort by
0
Wael
Top achievements
Rank 1
answered on 11 Jan 2013, 03:35 PM
Hey Kendo Team,

I am really enjoying using Kendo however iam facing almost the same issue as Mark. Using the editor template/DateTime, iam able to use the calendar from my razor view (grid)

columns.Bound(p => p.DateTo).Format("{0:d}").Width(80).Title("Date To");
 columns.Bound(p => p.DateFrom).Format("{0:d}").Width(80).Title("Date From");
Iam using a service which makes the update for me, here is the CRUD operation:

[AcceptVerbs(HttpVerbs.Post)]
        public StrategicGoal UpdateStrategicGoal(StrategicGoalHelper strategicGoal)
        {
            var sg = _context.StrategicGoals
                             .First(i => i.StrategicGoalId == strategicGoal.StrategicGoalId);
 
            sg.DateFrom = strategicGoal.DateFrom;
            sg.DateTo = strategicGoal.DateTo;
            sg.Name = strategicGoal.Name;
            sg.StrategicGoalDescription = strategicGoal.StrategicGoalDescription;
            _context.SaveChanges();
            return sg;
        }

and here is my controller which returns json

public ActionResult StrategicGoalUpdate([DataSourceRequest] DataSourceRequest request, StrategicGoalHelper strategicGoal)
        {
          if (strategicGoal != null && ModelState.IsValid)
              {
            _strategicGoalService.UpdateStrategicGoal(strategicGoal);
           }
            return Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet);
        }

When i choose date/ time from the kendo datetimepicker, it gives me this format 1/10/2013, when i press the update button, firebug returns this url: &DateFrom=Thu+Jan+03+2013+00%3A00%3A00+GMT%2B0100&DateTo=Thu+Jan+24+2013+00%3A00%3A00+GMT%2B0100&Goal=
with an Error (DBUpdateException)- {"The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.\r\nThe statement has been terminated."}

Here is what is defined in my model which uses entity framework code first:
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }

Any help would be appreciated since and i hope i made myself clear :-)






 
0
Vladimir Iliev
Telerik team
answered on 16 Jan 2013, 01:04 PM
Hi Mark,

 
From the provided information it's not clear for us what is the reason for this behavior - could you please send us a run-able example where the issue is reproduced?

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Date/Time Pickers
Asked by
Mark
Top achievements
Rank 1
Answers by
Wael
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or