title: Format Exception in View MVC C#
body: <p>The following is a snippet taken from my View Model:</p>
  
  <pre><code>[Display(Name = "Time")]
      [Required(ErrorMessage = "Is required field. Format hh:mm (24 hour time)")]
      [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:HH:mm}")]
      public Nullable&lt;System.TimeSpan&gt; EventPerformance_Time { get; set; }
  </code></pre>
  
  <p>And this is from my View.cshtml:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.EventPerformance_Time, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.EventPerformance_Time, "{0:HH:mm}", new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.EventPerformance_Time, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>When I run the project,  I keep getting the following error:</p>
  
  <blockquote>
    <p>FormatException: Input string was not in a correct format.  </p>
  </blockquote>
  
  <p>At line @Html.EditorFor.....etc.</p>
  
  <p>I have tried so many different 'solutions' and none have worked and I am so confused as to what is wrong because in another View Model it was working perfectly! </p>
  
  <p>Any help please? Much appreciated. </p>