zoukankan      html  css  js  c++  java
  • sharepoint 2010 使用自定义列表模版创建列表(2)

    前面用的方法是通过界面上操作,根据自定义模版,创建的列表。sharepoint 2010 使用自定义列表模版创建列表(1)

    这里顺便记录多另一种方法,通过程序来创建。

    ----------------------------------------------------------------------------------------------------------------------------------

    private void CreateListByCustomTemplate()

            {

                SPSite site = new SPSite("http://Win2012Moss");

                SPWeb web = site.OpenWeb();

                //指定要创建的自定义模板

                string TemplateName = "CommunityTemplate.stp";

                SPListTemplate CustomTemplate = null;

                SPListTemplateCollection ListTemplateCollection = web.Site.GetCustomListTemplates(web);

                foreach (SPListTemplate template in ListTemplateCollection)

                {

                    if (template.InternalName == TemplateName)

                    {

                        CustomTemplate = template;

                        break;

                    }

                }

                web.AllowUnsafeUpdates = true;

                string ListName = "ListName";

                Guid guidDiscussionBoard = web.Lists.Add(ListName, "", CustomTemplate);

                web.Update();

                web.Dispose();

            }

    ------------------------------------------------------------------------------------------------------------------------------

  • 相关阅读:
    用C#实现宽带重新拨号
    CALLBACK FUNCTION 回调函数
    编译程序 VS 解释程序
    《围城》读书笔记
    鼠标点击器
    工作与找工作的日子
    Windows 7下VS2003的查找无响应问题
    收藏几句关于程序的名言
    static知识小结
    如何定义和实现一个类的成员函数为回调函数(转)
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3285462.html
Copyright © 2011-2022 走看看