0 Comments

I was trying to change the displayname of a field in a dataform by placing the DisplayName attribute on the property in the metadata class. This will not work instead you must use the [Display(Name= "This is the correct display name")] attribute on the field in a metadata class:

[MetadataTypeAttribute(typeof(Product.ProductMetadata))]
    public partial class Product
    {
        internal sealed class ProductMetadata
        {

            // Metadata classes are not meant to be instantiated.
            private ProductMetadata()
            {
            }

            public int Id { get; set; }

            [Display(Name = "First Name", Description = "Employee's first name")] //Correct !
            //[DisplayName("First name 2")] // Wrong!
            public string Name { get; set; }

            public EntityCollection<ProductTag> ProductTag { get; set; }
        }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts