我有,其中包括一個虛擬列表,它是另一個類的鏈接一個實體類:MVC DataAnnotation顯示名稱不工作的虛擬物品
public virtual Employee Employee1 { get; set; }
所以在編輯頁面我有我的項目有標籤Employee1當我想「我的員工」,所以在我的DataAnnotation類中添加
[DisplayName("My Employee")]
public virtual Employee Employee1 { get; set; }
但它還沒有工作。 DataAnnotation類中的其他項目運行良好。
這可能會幫助:https://stackoverflow.com/questions/6405937/using-properties-settings-default-as-an-argument-for-displayname – drneel 2014-08-31 17:55:48
根據一來自Joshua Hayes的回答(http://stackoverflow.com/questions/2555759/wondering-why-displayname-attribute-is-ignored-in-labelfor-on-an-overridden-prop)使用DisplayAttribute而不是DisplayNameAttribute需要小心這個問題。 – Wouter 2014-08-31 18:03:13