Friday, May 16, 2008

Adding predefined list to site dynamically using SPListTemplateType

Many times we need to add predefined lists like Tasks List, WorkflowHistory List to our site using Code.

So here is the way we can accomplish this.

objClientsWeb.AllowUnsafeUpdates = true;

objClientsWeb.Lists.Add ( "{ListName}", "{Listdiscription}" ,SPListTemplateType.Tasks);

objClientsWeb.Lists.Add ( "{ListName}", "{Listdiscription}" ,SPListTemplateType.WorkflowHistory);

objClientsWeb.AllowUnsafeUpdates = false;

That's it your job is done.

Just Check user is having sufficient rights to add list to site.

No comments:




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com