dimanche 29 mars 2015

Time field receiving value from database, yet not showing

A form I'm working on uses DateTime values to represent a time property (TimeStart). I've got a viewmodel (CourseSectionSessionViewModel) with a corresponding editor template.


The viewmodel:



public class CourseSectionSessionViewModel
{
[Display(Name = "Start Time")]
[DataType(DataType.Time)]
[DisplayFormat(DataFormatString = "{0:hh:mm tt}", ApplyFormatInEditMode = true)]
public DateTime TimeStart { get; set; }
}


The editor template:



<tr>
<td>@Html.EditorFor(model => model.TimeStart, new { htmlAttributes = new { @class = "form-control", @data_val = "false" } })</td>
</tr>


Both above have extraneous items excluded for brevity.


This results in the following image, which shows the fields, and the inspector indicates the fields have been populated (and debugging with Visual Studio confirms the actual data are coming from the DB), yet the visual looks like a default value.


Time fields


The actual value seems to be getting added to the form field, yet the field is not evidently showing the value. Any suggestions?


Aucun commentaire:

Enregistrer un commentaire