在 ASP.NET 动态数据外键显示中组合多个字段
我在动态数据站点中有两个表(人员和位置)
,在添加位置信息时,我需要从通过 FK 填充的下拉框中选择一个人。该下拉框默认为“Person”中标题为“fname”的字段,即名字,因此它看起来像“Jim”或“Steve”。
我试图让该下拉框显示它引用的人的全名,该人将组合字段 fname 和 lname。
我会在字段模板中执行此操作吗?元数据?我有点坚持这个。
如果我查看ForeignKey_Edit的FieldTemplate,我会看到这一点:
protected void Page_Load(object sender, EventArgs e)
{
if (DropDownList1.Items.Count == 0)
{
if (Mode == DataBoundControlMode.Insert || !Column.IsRequired)
{
DropDownList1.Items.Add(new ListItem("[Not Set]", ""));
}
PopulateListControl(DropDownList1);
}
SetUpValidator(RequiredFieldValidator1);
SetUpValidator(DynamicValidator1);
}
似乎我应该能够制作类似于“PopulateListControl”的东西并使用它,但我不知道这个方法驻留在哪里。
有什么想法吗?
I have two tables (Person and Location)
In the Dynamic Data Site, when adding Location info, I am need to choose a person from the dropdown box which is populated via a FK. That dropdown box defaults to the field in "Person" that is titled "fname" which is first name, so it looks like "Jim" or "Steve".
I'm trying to have that dropdown box display the full name of the person it references which would be combining the fields fname and lname.
Would I do this inside a Field Template? Metadata? I'm kind of stuck on this.
If I look at the FieldTemplate for ForeignKey_Edit I see this:
protected void Page_Load(object sender, EventArgs e)
{
if (DropDownList1.Items.Count == 0)
{
if (Mode == DataBoundControlMode.Insert || !Column.IsRequired)
{
DropDownList1.Items.Add(new ListItem("[Not Set]", ""));
}
PopulateListControl(DropDownList1);
}
SetUpValidator(RequiredFieldValidator1);
SetUpValidator(DynamicValidator1);
}
and it seems like I should be able to make something similar to "PopulateListControl" and use that instead, but I have no idea where this method even resides.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了。我需要重写类的 ToString() 方法以返回属性组合。
Found it. I needed to override the ToString() method of my class to return a combination of properties.