列表模板未应用于新的Sharepoint列表

时间:2014-07-11 17:14:19

标签: c# sharepoint console-application sharepoint-list

正在使用Sharepoint.client创建SharePoint列表,但未应用该模板。我在新列表中看不到任何字段/列。提出了类似的问题here,但它的答案对我不起作用。非常感谢任何帮助!

        using (ClientContext context = new ClientContext(SITE))
        {
            Web web = context.Web;
            context.Load(web);
            context.ExecuteQuery();

            ListTemplate template = null;
            ListTemplateCollection ltc = context.Site.GetCustomListTemplates(web);
            //ListTemplateCollection ltc2 = web.ListTemplates;
            context.Load(ltc);
            context.ExecuteQuery();

            foreach (ListTemplate t in ltc)
            {
                if (t.Name == "My_Template")
                {
                    template = t;
                    break;
                }
            }

            var listCreationInfo = new ListCreationInformation
            {
                Title = "Test_List",
                Description = "Test"
            }; 
            //ListTemplate listTemplate = ltc.First(listTemp => listTemp.Name.Contains("My_Template"));
            listCreationInfo.TemplateFeatureId = template.FeatureId;
            listCreationInfo.TemplateType = template.ListTemplateTypeKind;


            listCreationInfo.QuickLaunchOption = QuickLaunchOptions.On;                
            List oList = web.Lists.Add(listCreationInfo);
            context.ExecuteQuery();
    }

0 个答案:

没有答案