开发 SharePoint 自定义 Web 部件。如何渲染查找字段?
我需要将列表中的查找字段呈现为带有弹出对话框的链接(与在默认 SharePoint 2010 列表视图中呈现查找字段的方式相同)。如果我有包含查找字段的 SPListItem 对象,我该怎么做?也许有一些控制来渲染查找字段?
protected void Page_Init(object sender, EventArgs e)
{
SPQuery query = new SPQuery();
query.Query = "some query here";
SPListItemCollection items = __list.GetItems(query);
foreach (SPListItem item in items)
{
// render item["lookup_field_name"] somehow
}
}
I need to render lookup field from a list as a link with popup dialog (the same way as lookup fields are rendered in default SharePoint 2010 list view). How can I do that if I have SPListItem object that contains lookup field? Maybe there is some control to render lookup fields?
protected void Page_Init(object sender, EventArgs e)
{
SPQuery query = new SPQuery();
query.Query = "some query here";
SPListItemCollection items = __list.GetItems(query);
foreach (SPListItem item in items)
{
// render item["lookup_field_name"] somehow
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果 SPQuery 对象检索列表项,它将包含一个值,您只需检查该值是否为 null。
这意味着当您请求查找列时,查找列不会被填充,而是会填充它们在创建时携带的任何内容。
If a list item is retrieved by the SPQuery object it will have a value in it, all you have to check is wether the value is null or not.
This means that lookup columns does not get filled when you ask for them, the are filled with whatever content they carry when they are created.