Online Training On SharePoint
                      
Showing posts with label code to create SharePoint lists using list template. Show all posts
Showing posts with label code to create SharePoint lists using list template. Show all posts

Friday, 26 June 2009

Creating a SharePoint List based on a List Template using Object Model

We can create a SharePoint list based on List Template available. We were using SharePoint Object Model to create the lists dynamically based on a specific List template. Following is the code snippet which can be used for this purpose:

SPSite _site = new SPSite("http://localhost");
SPWeb _web = _site.OpenWeb();
SPListTemplateCollection listcoll = _web.Site.GetCustomListTemplates(_web);
_web.Lists.Add("ListName", "List Descriptioon", listtempcol["TemplateName"]);
SPList _list = oweb.Lists["ListName"];
_list.OnQuickLaunch = true;
_list.Update();
_web.Dispose();
_site.Dispose();
Related Posts with Thumbnails