sharepoint 2010 使用自定义列表模版创建列表(2)
2013-08-27 14:08
561 查看
前面用的方法是通过界面上操作,根据自定义模版,创建的列表。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 使用自定义列表模版创建列表(2)
- sharepoint 2010 使用自定义列表模版创建列表(1)
- SharePoint 2010 使用自定义aspx页面替换列表默认的新建(NewForm.aspx),查看(DispForm.aspx)和编辑(EditForm.aspx)页面
- sharepoint 2010 自定义字段开发(1) 创建一个简单的列表自定义字段
- 在 SharePoint 2010 中创建自定义列表定义
- SharePoint 2010 创建联系人列表和使用联系人列表
- SharePoint 2010 创建联系人列表和使用联系人列表
- SP2010开发和VS2010专家"食谱"--第四章节—列表定义和内容类型(3)--使用对象模型创建自定义内容类型
- SharePoint 2010 使用自定义aspx页面替换列表默认的新建(NewForm.aspx),查看(DispForm.aspx)和编辑(EditForm.aspx)页面
- SP2010开发和VS2010专家"食谱"--第四章节—列表定义和内容类型(3)--使用对象模型创建自定义内容类型
- sharepoint 2010 创建一个简单的列表自定义字段
- SharePoint 2010 使用自定义aspx页面替换列表默认的新建(NewForm.aspx),查看(DispForm.aspx)和编辑(EditForm.aspx)页面
- SharePoint 2010 使用自定义aspx页面替换列表默认的新建(NewForm.aspx),查看(DispForm.aspx)和编辑(EditForm.aspx)页面
- 使用自定义任务审批字段创建 SharePoint 顺序工作流
- SharePoint 2010 工作流解决方案:创建自定义网站工作流活动
- MOSS 2010:Visual Studio 2010开发体验(20)——使用ADO.NET Data Service快速访问SharePoint列表数据
- [SharePoint 2010 的那些事儿-InfoPath]使用InfoPath表单筛选SharePoint列表数据
- SharePoint 自定义列表页面定制续—[保存模板后不能正常使用]
- sharepoint 2010 如何给文档库或自定义列表添加评论功能