Search code examples
asp.netasp.net-dynamic-data

How to change the DisplayName of a table in ASP.Net Dynamic Data


I'm new to Dynamic Data. I want to change the DisplayName of tables in Default.aspx page so I can set meaning full names for them. Also I want to change column names of tables when I List, Edit and Insert mode. How can I do that in c# language?


Solution

  • You can do this by setting the DisplayName (from System.ComponentModel) attribute on each table. For this you'll need a partial class for each table that you're scaffolding with Dynamic Data e.g.

    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel;
    
    ...
    
    [ScaffoldTable(true)]
    [DisplayName("Northwind Products")]
    partial class Product
    {
    }
    

    renders...

    enter image description here