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

UpdateModel with TimePicker values fails

0 Answers 43 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.
Bill
Top achievements
Rank 1
Bill asked on 18 Nov 2011, 08:06 AM
I have a DateTime field that doesn't seem to update when I use a TimePicker and the UpdateModel<> method. I get
generic .Net error when I try to do this. The only way is to manually bind with something like:
ol.ModifiedBy = Collection["ArrivalTime"];  Any ideas why?

VIEW
<%= Html.Telerik().TimePicker()
    .Name("ArrivalTime")
    .Value(Model.ArrivalTime)
    .ShowButton(false)                     
%>                         
<br /><%: Html.ValidationMessageFor(model => model.ArrivalTime)%> (MVC VALIDATION DOES NOT WORK EITHER!!!)
CONTROLLER 
[HttpPost]         
public ActionResult Edit_Location(int LocationId, FormCollection collection)         
{             
    Location ol = _db.Locations.First(l => l.LocationId == LocationId);             
    try             
        {                 
            UpdateModel<Location>(ol, "", collection.ToValueProvider());                 
            ol.ModifiedBy = CurrentUserName;                 
            ol.ModifiedOn = DateTime.Now;                 
            _db.SaveChanges();                 
            return RedirectToAction("Details_Location""Location"new { LocationId = ol.LocationId });
        }             
    catch (Exception ex)             
        {                 
            return PartialView(ol);             
        }                      
}


Tags
Date/Time Pickers
Asked by
Bill
Top achievements
Rank 1
Share this question
or