If you've defined a custom DisplayTemplate, is there some way to use the DisplayFormat.DataFormatString defined for that object?
For example, I've defined a DisplayTemplate for Double:
<div class="form-group">
@Html.Label("", ViewData["label"] as string, new { @class = "col-sm-6" })
<p class="col-sm-6">
@Html.DisplayTextFor(m => m)
</p>
</div>
Then my model defines a DisplayFormat:
[Display(Name = "In Weight")]
[DisplayFormat(DataFormatString = "{0} lb")]
public double? InWeight{ get; set; }
In the above example, DisplayTextFor only provides a simple ToString(), while replacing it with DisplayFor renders nothing.
@Html.Label()when you do not have an associated form control. The reasonDisplayFor()would not work is that it would keep calling itself. You could access the propertiesModelMetadatato generate the formatted valuedldescription list in this case, but the question would be the same for formatting the value.