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

流过昼夜 提交于 2020-01-06 01:48:06

问题


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?


回答1:


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...




回答2:


Just for anyone else seeing this post I had the same requirements as the original poster. I tried the suggestions and these still didn't work. I found out (this might be obvious) that you need to ensure you have a "namespace" declaration in your partial class. The namespace needs to be the same as the entity model you are using i.e. under App_Code you should have a Model.designer.cs file - your namespace needs to be the same as



来源:https://stackoverflow.com/questions/10511433/how-to-change-the-displayname-of-a-table-in-asp-net-dynamic-data

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