更改下拉列表中显示的字段

时间:2009-11-03 17:20:20

标签: asp.net dynamic-data

我有一个动态数据网站,在将记录插入表格时,显示为下拉列表的外键关系使用错误的字段作为其选择项目文本值。

如何更改下拉菜单,以便在使用这一个表时,它会使用不同的列作为下拉列表中的值?

谢谢

1 个答案:

答案 0 :(得分:1)

解决方案是添加一个部分类,其中包含System.ComponentModel.DataAnnotations命名空间中的一些属性。部件。请注意下面的 [DisplayColumn(“Description”)] 。这就是用于呈现列表中文本的字段。

Further reading

[MetadataType(typeof(ProductMetadata))]
**[DisplayColumn("Description")]**
[ScaffoldTable(true)]
public partial class Product
{
}

public class ProductMetadata
{
    [UIHint("TextReadOnly")]
    public string CreatedBy;

    [UIHint("TextReadOnly")]
    public string CreatedDate;

    [ScaffoldColumn(false)]
    public EntityCollection<OrderItem> OrderItem;
}