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

[Solved] mvc Date Time Picker setting different values on add and edit

0 Answers 114 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Joseph
Top achievements
Rank 1
Joseph asked on 04 May 2012, 11:36 AM
Hi,

I would like to know if it is possible to enter different dates using javascipt.

this is in a template in a gridview shown OnEdit()
@(Html.Telerik().DateTimePickerFor(item => item.DateTimeStart)
                  .Name(ViewData.TemplateInfo.GetFullHtmlFieldName("DateTimeStart")))


function OnEdit()
if (e.mode == "insert") {
            var datepicker = $('#DateTimeStart').data("tDateTimePicker");
            datepicker.value("11/05/2012"); //this is going to be the value that I will set later on
        }

        if (e.mode == "edit") {
            var datepicker = $('#DateTimeStart').data("tDateTimePicker");
          
            bookDateTime = dataItem["DateTimeStart"];
            datepicker.value(bookDateTime);
            alert(bookDateTime)
            
        }

It is working properly but the value in the datepicker is not updated when you open it at the first time.  The second time I Open it, it works properly.  I don't know what can be the problem. Can you please help me to figure out since its my first time to post here
Tags
Date/Time Pickers
Asked by
Joseph
Top achievements
Rank 1
Share this question
or