使用SPListCollection.Add

时间:2012-01-09 17:04:01

标签: sharepoint sharepoint-2010 splist

有人可以告诉我如何使用SPListCollection.Add(String, String, String, String, Int32, String, String, SPFeatureDefinition, SPListTemplate.QuickLaunchOptions) Method吗?

  • featureId参数的用途是什么?
  • listInstanceFeatureDefinition参数的用途是什么?
  • 哪些参数是可选/必需的?
  • url参数的格式是什么?

提前致谢!

2 个答案:

答案 0 :(得分:1)

继续运行相同的codeplex链接......对于该方法的特定实现不是很有帮助。经过一些试验和错误,我确实让这个工作了,它确实绕过了无效的列表模板"尝试从自定义内容类型创建列表时出错(即BaseTemplate> 100000)。该函数从一个SPWeb获取SPList定义(ListToCopy)并将其复制到另一个SPWeb(NewWeb)。现在唯一缺少的链接是最后一个参数docTemplateType,我被迫手动指定(101 - MS Word)。不确定如何从源列表中获取该文件。

public static Guid CopyListDefToAWeb(String SourceWebUrl, SPList ListToCopy, SPWeb NewWeb)
    {
        Guid newListGuid = Guid.Empty;
        if (Convert.ToInt32(ListToCopy.BaseTemplate) < 10000)
        {
            newListGuid = NewWeb.Lists.Add(ListToCopy.Title, ListToCopy.Description, ListToCopy.BaseTemplate);
        }
        else
        {
            String newListUrl = ListToCopy.Title.Replace(" ", String.Empty);
            newListGuid = NewWeb.Lists.Add(ListToCopy.Title, ListToCopy.Description, newListUrl, ListToCopy.TemplateFeatureId.ToString(), Convert.ToInt32(ListToCopy.BaseTemplate), "101");
        }

        return newListGuid;
    }

答案 1 :(得分:0)

虽然您为MSDN提供的链接清楚地解释了每个参数,但这里有一些关于如何使用它的示例

http://spcore.codeplex.com/SourceControl/changeset/view/62542#1079698

相关问题