Fabio de Miranda
Fabio de Miranda

Reputation: 1096

ASP.Net DynamicData pages scaffolded from DB tables: is there a simple way to change their names?

ASP.net scaffolding creates administrative page names by adding a 'S' to the name of the table. Thus the editing page for User table is named Users, and so on.

Is there a simple way of changing that name without creating custom pages?

For instance for the table "Business" I'd like ASP.net DynamicData to create an administrative link named "Businesses" appearing at the front page instead of the very ugly "Businesss" I'm getting now.

Of course I don't care about the name that will appear in the routed URL, just want the front page to have the name appearing correctly.

Upvotes: 1

Views: 223

Answers (1)

Aaron Hoffman
Aaron Hoffman

Reputation: 6962

Yes, use the DisplayName attribute. It can be used on both Classes and Properties.

http://msdn.microsoft.com/en-us/library/system.componentmodel.displaynameattribute.aspx

Example:

[MetadataType(typeof(OrderDetailsMetadata))]
public partial class OrderDetails
{
    public const string DisplayName_UnitPrice = "Unit Price";
}

[DisplayName("Order Details")]
public partial class OrderDetailsMetadata
{
    [DisplayName(OrderDetails.DisplayName_UnitPrice)]
    public Decimal UnitPrice { get; set; }
}

Upvotes: 4

Related Questions