Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to create custom calendar list programatically.

SPListTemplate template = web.ListTemplates["Calendar"];
var newListID = web.Lists.Add(fromTitle, description, template);

But i cannot do this because of out of range exception! Calendar template cannot be found!

But when site is created i can see Calendar template in list of templates!

Also those two features is activated before my code

public Guid GroupWorkLists = new Guid("9c03e124-eef7-4dc6-b5eb-86ccd207cb87");

public Guid TeamCollaborationLists = new Guid("00bfea71-4ea5-48d4-a4ad-7ea5c011abe5");

What i am doing wrong and why i cannot get calendar list template?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Try web.ListTemplates["Events"] or web.ListTemplates[106].

SPListTemplateType enumeration

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.