问题
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