[英]Retrieve document template type from SPList
在SharePoint中工作时,我正在使用以下方法创建自定义SPList:
从MSDN :
public virtual Guid Add(
string title,
string description,
string url,
string featureId,
int templateType,
string docTemplateType,
SPListTemplate.QuickLaunchOptions quickLaunchOptions
)
传递docTemplateType来声明文档模板类型。 是否可以从现有的SPList中检索文档模板类型? 这可能很有用,即在复制列表时。
提前致谢。
使用SPList.BaseTemplate属性可获取列表所基于的列表定义类型,例如:
SPList list = web.Lists.TryGetList(<list title>);
SPListTemplateType templateType = list.BaseTemplate;
int templateTypeId = (int) templateType;
SPList list = web.Lists.TryGetList(<list title>);
var docTemplate = web.ListTemplates.OfType<SPListTemplate>()
.FirstOrDefault(lt => lt.Type == list.BaseTemplate);
Console.WriteLine(docTemplate.DocumentTemplate);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.