Let’s say I hav this model:
public class PartyGorilla
{
[ScaffoldColumn(false)]
public int Id{ get; set; }
[DisplayName("Gorilla's Name")]
[Required]
public string Name{ get; set; }
}
Everything works as desired when using EditorForModel() in my edit/create views but if I use DisplayForModel() in my details view the Id property is not being shown, which is not what I want. My question is: is there another attribute I need to ad or do I need to cook up a custom one?
I would just add the
LabelForDisplayFortheidcolumn before theDisplayForModel. I don’t really see a simpler solution to that problem.You could also make a separate ViewModel, but that has a nasty non-dry footprint for what it actually accomplishes: