Online Training On SharePoint

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;
Post a Comment
Related Posts with Thumbnails