Managing (Save & Delete) List Templates programmatically in SharePoint

Asked By eliza sahoo
09-Feb-10 07:30 AM
Earn up to 0 extra points for answering this tough question.
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 = newSPSite("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

http://www.mindfiresolutions.com/

  re: Managing (Save & Delete) List Templates programmatically in SharePoint

Alon Havivi replied to eliza sahoo
09-Feb-10 02:01 PM
Again, thanks for the sample... remember it's better to publish your knowledge base on the FAQ section.
Create New Account