Reputation: 45
When working in SharePoint I am creating a custom SPList using the following method:
From MSDN:
public virtual Guid Add(
string title,
string description,
string url,
string featureId,
int templateType,
string docTemplateType,
SPListTemplate.QuickLaunchOptions quickLaunchOptions
)
The docTemplateType is passed to declare the document template type. Is it possible to retrieve the document template type from an existing SPList? This can be useful i.e. when copying a list.
Thanks in advance.
Upvotes: 0
Views: 1231
Reputation: 59378
Use SPList.BaseTemplate property to get the list definition type on which the list is based, for example:
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);
Upvotes: 2