开发 SharePoint 自定义 Web 部件。如何渲染查找字段?

发布于 2024-11-18 05:22:40 字数 434 浏览 11 评论 0原文

我需要将列表中的查找字段呈现为带有弹出对话框的链接(与在默认 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 技术交流群。

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

发布评论

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

评论(2

蓝戈者 2024-11-25 05:22:40
spfieldlookupvalue value=new SpFiledlookupvalue(item["column name"]);
string id=value.lookupid;//you can retrieve the text,id
string text=value.lookuptext;
spfieldlookupvalue value=new SpFiledlookupvalue(item["column name"]);
string id=value.lookupid;//you can retrieve the text,id
string text=value.lookuptext;
若能看破又如何 2024-11-25 05:22:40

如果 SPQuery 对象检索列表项,它将包含一个值,您只需检查该值是否为 null。

foreach (SPListItem item in items)
{
    if(item != null)
    {
        // render item["lookup_field_name"] somehow
    }
}

这意味着当您请求查找列时,查找列不会被填充,而是会填充它们在创建时携带的任何内容。

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.

foreach (SPListItem item in items)
{
    if(item != null)
    {
        // render item["lookup_field_name"] somehow
    }
}

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.

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