How do I set the “Display(Name = ”“)” data annotation on dropdownlists from the source model?

寵の児 提交于 2019-12-11 13:30:31

问题


When I try to set the Display(Name = "") attribute on a foreign key field in the model, the Display Name does not render in the view (i.e. the Display Name remains as the column name in the model).

See the example below:

[Display(Name = "Phone Number")]
public long Phone_Number { get; set; }

[Display(Name = "Phone Type")]
public int Phone_Type_Name { get; set; }

Note: The Phone_Type_Name field is a foreign key of the model Phone_Type. The view for this model does not render Phone Type, but instead Phone_Type_Name.

What's wrong with my code?

来源:https://stackoverflow.com/questions/21868360/how-do-i-set-the-displayname-data-annotation-on-dropdownlists-from-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!