This is a migrated thread and some comments may be shown as answers.
Two DatePickers, second value not being stored.
1 Answer 41 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
John
Top achievements
Rank 1
John asked on 16 Dec 2010, 11:55 PM
I have a search page and i have two date pickers allowing the user to set a date range, and im having some trouble. I am using model binding, and i have this:
            <div class="optionsCol1">
                <%:Html.Label("Invoice Number:")%>
                <%:Html.TextBoxFor(model => model.InvoicePartial)%>

                <%:Html.Label("Company:")%>
                <%:Html.DropDownListFor(model=> model.CompanyId, ViewData["CompanyBox"] as SelectList,new {id = "companyId"})%>
                        
                <%:Html.Label("From Date:")%>
                <%:Html.Telerik().DatePickerFor(model => model.FromDate)
                    .Min(new DateTime(2010, 12, 01))
                    .Max(DateTime.Now)
                    .Value(Model.FromDate)%>

            </div>
            
            <div class="optionsCol2">
                <br /><br /><br />
                <%:Html.Label("Field Office:")%>
                <%:Html.DropDownListFor(model => model.FieldOfficeId, ViewData["FieldOfficeBox"] as SelectList,new {id = "fieldOfficeId"})%>
                                
                <%:Html.Label("To Date:")%>
                <%:Html.Telerik().DatePickerFor(model => model.FinalDate)
                    .Min(new DateTime(2010, 01, 01))
                    .Max(DateTime.Now)
                    .Value(Model.FinalDate)%>

            </div>

Now,  when i submit the form that they are on, the second date is not stored. It always comes back as 01/01/0001 and thus preventing the search. (By second one i mean model.FinalDate) Now, it does the same thing when im using a formcollection aswell. I am using the q3 build of the telerik mvc tools.
Is there any problem that it could be? Also, put the dates in, in reverse order it works. So if i assign final date, then from date, it works.

1 Answer, 1 is accepted

Sort by
0
Mathieu
Top achievements
Rank 1
answered on 01 Apr 2011, 03:58 PM
Hi,

I have the exact same problem here. I tried adding several Datetime fields to my model and everytime, the first one that appear in the definition gets saved properly but all the others gets the value 1/1/0001.

Any solutions?

Thx
Tags
Date/Time Pickers
Asked by
John
Top achievements
Rank 1
Answers by
Mathieu
Top achievements
Rank 1
Share this question
or