sharepoint 2010 使用自定义列表模版创建列表(2)
2013-08-27 17:44
501 查看
前面用的方法是通过界面上操作,根据自定义模版,创建的列表。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();
}
------------------------------------------------------------------------------------------------------------------------------
这里顺便记录多另一种方法,通过程序来创建。
----------------------------------------------------------------------------------------------------------------------------------
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();
}
------------------------------------------------------------------------------------------------------------------------------
相关文章推荐
- sharepoint 2010 使用自定义列表模版创建列表(1)
- sharepoint 2010 使用自定义列表模版创建列表(1)
- sharepoint 2010 使用自定义列表模版创建列表(2)
- SharePoint 2010 使用自定义aspx页面替换列表默认的新建(NewForm.aspx),查看(DispForm.aspx)和编辑(EditForm.aspx)页面
- SharePoint 2010 使用自定义aspx页面替换列表默认的新建(NewForm.aspx),查看(DispForm.aspx)和编辑(EditForm.aspx)页面
- SharePoint 2010 使用自定义aspx页面替换列表默认的新建(NewForm.aspx),查看(DispForm.aspx)和编辑(EditForm.aspx)页面
- sharepoint 2010 自定义字段开发(1) 创建一个简单的列表自定义字段
- SP2010开发和VS2010专家"食谱"--第四章节—列表定义和内容类型(3)--使用对象模型创建自定义内容类型
- SharePoint 2010 创建联系人列表和使用联系人列表
- 在 SharePoint 2010 中创建自定义列表定义
- SharePoint 2010 创建联系人列表和使用联系人列表
- SharePoint 2010 使用自定义aspx页面替换列表默认的新建(NewForm.aspx),查看(DispForm.aspx)和编辑(EditForm.aspx)页面
- SP2010开发和VS2010专家"食谱"--第四章节—列表定义和内容类型(3)--使用对象模型创建自定义内容类型
- sharepoint 2010 创建一个简单的列表自定义字段
- 如何在SharePoint 2010中创建自定义字段类型
- SharePoint 2010开发工具图解系列:Visual Studio 2010创建列表
- 帝国自定义列表模版使用方法
- 使用SharePoint创建并自定义网站页面
- 为SharePoint 2010中的FBA创建自定义登录页面
- sharepoint 2010 自定义列表启用版本记录控制 如何在修改数据不产生新版本