2012-04-13 168 views

回答

2

嘗試SPListCollection.Add覆蓋,包括功能ID和模板類型:

site.Lists.Add("MyLibrary", 
    "MyLibrary", 
    "MyLibrary", 
    "{2510d73f-7109-4ccc-8a1c-314894deeb3a}", 
    433, 
    "101"); 
1

一個SPList.Add的()重載需要一個SPListTemplate(不SPListTemplateType您使用ENUM)

http://msdn.microsoft.com/en-us/library/ms477358.aspx

首先抓取SPListTemplate,然後用它來添加列表:

SPListTemplate reportTemplate = site.ListTemplates["Report Library"]; // note displayname, so might be different depending on language 
Guid listGuid = site.Lists.Add("MyLibrary","MyDescription",reportTemplate);