为什么ForeignKey_Edit加载主键作为值,而不是关联中使用的实际值?

发布于 2024-07-24 02:57:24 字数 461 浏览 1 评论 0原文

我正在使用 ASP.NET 动态数据创建票证编辑表单。 票证与问题代码关联,但不使用问题代码的主键。 (数据库是第3方,所以我无法控制它......)

所以问题代码看起来基本上是这样的:

ProblemCode
(
    ID int,
    Code varchar(8),
    Description varchar(250)
)

关联是 Ticket.ProblemCode 和 ProblemCode.Code

现在的问题是foreignKey_Edit(实际上是 PopulateListControl)填充主键为 ID 的下拉菜单...但票证实际上是使用代码将两者联系在一起。 我错过了什么吗? 有没有一种简单的方法让它使用 Code 作为值?

如果没有,我可能可以从视图中删除 ID,因为我认为它不必在任何地方使用......我只是喜欢有一个 ID。

I'm using ASP.NET dynamic data to create a ticket edit form. The Ticket is associated to a problem code, but not using the problem code's primary key. (The database is 3rd party, so I don't have control over that...)

So the problemCode looks basically like:

ProblemCode
(
    ID int,
    Code varchar(8),
    Description varchar(250)
)

The association is between Ticket.ProblemCode and ProblemCode.Code

Now the problem is that ForeignKey_Edit (really, PopulateListControl) fills the dropdown with the Primary Key which is ID... but the ticket is actually using Code to tie the two together. Am I missing something? Is there a simple way to get it to use Code as the value instead?

If not I can probably eliminate ID from the view as I don't think it HAS to be used anywhere... I just like having an ID around.

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

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

发布评论

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

评论(1

左耳近心 2024-07-31 02:57:24

在您的元数据中尝试以下操作:

[DisplayColumn("Code")] 
public partial class ProblemCode{ }

Try this in your metadata:

[DisplayColumn("Code")] 
public partial class ProblemCode{ }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文