Software Technology Tips

List Templates
List templates are predefined layouts available in SharePoint which can be used to create new content quickly and easily .The List templates are maintained within the site collection List template gallery. Sharepoint provides OOTB functionality to create and delete list templates. Below mentioned are ways to Save a list as List Template and deleting a list template from the List Template Gallery programmatically.
 
 
Saving a List Template
 
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSPsite = new SPSite("http://myserver/site"))
{
using (SPWeb oSPWeb = oSPsite.OpenWeb())
{
SPList lstSource = oSPWeb.Lists["SourceList"];
lstSource.SaveAsTemplate("FileName.stp", "Name", "Description", false);
lstSource.Update();
}
}
}); //end elivated privileges
 
Deleting a List Template
 
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSPsite = new SPSite("http://myserver/site"))
{
using (SPWeb oSPWeb = oSPsite.OpenWeb())
{
SPList objLstTempGallery = oSPWeb.Lists["List Template Gallery"];
 
foreach (SPListItem objLstItem in objLstTempGallery.Items)
{
if (objLstItem.Title == "DEL_LIST_TEMPLATE_NAME")
{
objLstItem.Delete();
objLstTempGallery.Update();
break;
}
}
}
}
}); //end elivated privileges


Related Tags:

SharePoint

Author: Saroj Dash

Related Pages

  • SharePoint Development Expertise
  • SharePoint Application Projects

SharePoint

Let us Connect!

Awards and Achivements

Red Herringcolor DeloitteFast50 DB ZInnov1   Nascome

Events

serf DDM

This site uses cookies. We respect your privacy.copyright (c) Mindfire Solutions 2007-2015. Login