Reputation: 5447
I have the following TimeSpan variable in my Model class:
[DisplayFormat(DataFormatString = "{0:HH-mm}", ApplyFormatInEditMode = true)]
public TimeSpan StartingHour { get; set; }
But when I call it from my View I got the error:
@Html.DisplayFor(modelItem => item.StartingHour)
System.FormatException: Input string was not in a correct format.
The value of the variable is: "18:00:00".
What should be in my DisplayFormat initialization? And please keep "get hour and minute separately from the time" advices to yourself.
Upvotes: 3
Views: 5083