2

我已经根据问题列表创建了一个列表模板,它保存在列表模板库中。现在如何根据这个模板创建一个新列表?

4

4 回答 4

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);
于 2009-06-03T14:46:47.093 回答
3

I just encountered the same situation today.
I saved a list as a template and i wanted to use that template in a new list.
On Sharepoint 2013, go to Site Contents > Add an App >
Scroll down and you will see a page numbering saying that you are on page 1
Click on the second page and all your saved templates will be there

于 2016-01-03T11:20:18.870 回答
0

计时器作业可能只需要一段时间才能触发。

Lists > Create > Tracking section几分钟后,该模板最终显示为一个选项。

于 2009-06-08T19:57:53.290 回答
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 }
于 2014-04-02T08:28:55.220 回答