【问题标题】:Get a List using its ID使用其 ID 获取列表
【发布时间】:2010-07-28 14:51:13
【问题描述】:

我正在尝试使用它的 ID 获取列表,但是它不起作用,我不知道为什么

这没有问题...

using (SPSite site = new SPSite("http://example.org/sites/specific/staffhandbook"))
using (SPWeb web = site.OpenWeb())
    {
        SPList list = web.Lists["Documents"];
        // process...
    }

应该这样,但不是吗?

using (SPSite site = new SPSite("http://example.org/sites/specific/staffhandbook"))
using (SPWeb web = site.OpenWeb())
    {
        SPList list = web.Lists["29540646-bcab-4beb-8a91-648c1f3178b8"];
        // process...
    }

【问题讨论】:

    标签: c# sharepoint sharepoint-2007


    【解决方案1】:

    SPListCollection 接受 Int32(索引)、String(列表名称)或 Guid(标识符),因此您需要执行上述操作:

    Guid guid = new Guid("29540646-bcab-4beb-8a91-648c1f3178b8");
    SPList list = web.Lists[guid];
    

    【讨论】:

    • 哇!即使我在看一个例子我仍然没有看到它,谢谢:-)
    猜你喜欢
    • 2022-11-12
    • 2019-12-31
    • 1970-01-01
    • 1970-01-01
    • 2021-02-03
    • 1970-01-01
    • 2014-07-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多