2009-06-03 43 views

回答

0

这可能只是需要一段时间才能开始定时器工作。

模板在几分钟后最终显示为Lists > Create > Tracking section下的选项。

3
string internalName = "MyListTemplateName"; 
SPListTemplate t = null; 
    foreach (SPListTemplate template in web.ListTemplates) 
    { 
     if (template.InternalName.Equals(internalName) 
     { 
      t = template; 
      break; 
     } 
    }  
     web.Lists.Add("nameoflist", "description", t); 
0

我很惊讶Johan Leino的答案被多次标记为有用,因为它在这个特殊情况下不起作用。如果您自己创建模板,web.ListTemplates不存储它,您将无法创建列表。它只适用于开箱即用的模板。
如果您要根据您的自定义模板创建一个列表,你需要做的是这样的:

SPListTemplateCollection listTemplates = web.Site.GetCustomListTemplates(web); 
SPListTemplate listTemplate = listTemplates["MyCustomTemplate"]; 
Guid listId = web.Lists.Add("My New List Name", "My Description", listTemplate); 
if (listId != null) { //all good } 
2

我只是今天遇到了同样的情况。
我保存了一个列表作为模板,我想在新列表中使用该模板。
在SharePoint 2013,去网站内容>添加一个应用程序>
向下滚动,你会看到一个页码说你页面上
点击第二页上,你的所有保存的模板将be there

相关问题