Reputation:
Inside a DisplayTemplate I can always access the value of the property I want to render by accessing ViewData.Model
.
Is there a way to access the instance of the model that the property I'm rendering belongs to from inside the template?
For example:
public class IndexModel
{
public DateTime Date { get; set; }
[UIHint("Value")]
public double? Value { get; set; }
}
Then inside the Index.cshtml I have:
@model TestMVC3.Models.Home.IndexModel
@Html.DisplayFor(m => m.Value)
I'd like to know if there is a way to access the instance of type IndexModel (that I could access from Index.cshtml using the Model property), from the Value.cshtml DisplayTemplate
Upvotes: 1
Views: 76