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

发布于 2024-08-09 15:36:38 字数 114 浏览 4 评论 0原文

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

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

谢谢

I have a Dynamic Data website and while inserting a record into a table, the foreign key relationship shown as a drop-down uses the wrong field for it's select item text value.

How can I change the drop-down such that when working with this one table, it will use a different column as the value in the drop-down?

thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰火雁神 2024-08-16 15:36:38

解决方案是添加一个带有 System.ComponentModel.DataAnnotations 命名空间中的一些属性的分部类。集会。请注意下面的[DisplayColumn("Description")]。这就是用于呈现为列表中文本的字段。

进一步阅读

[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;
}

The solution is to add a partial class with some attributes from the System.ComponentModel.DataAnnotations namespace & assembly. Notice the [DisplayColumn("Description")] below. That's what field is used to render as the text in a list.

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文