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?


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

SPListTemplateType enumeration

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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