Create List from Custom List Template Programmatically in SharePoint

Below is the code in which you have to send parameter :

strSiteURL: Site URL on which you have to create List using template.

strTemplateName: Template name of which you have to create list

strListName: Name of the list.

public void CreateListFromTemplate(string strSiteURL,string strTemplateName,string strListName)

{

SPSecurity.RunWithElevatedPrivileges(delegate

{

using (SPSite oSPsite = new SPSite(strDestinationURL))

{

oSPsite.AllowUnsafeUpdates = true;

using (SPWeb oSPWeb = oSPsite.OpenWeb())

{

oSPWeb.AllowUnsafeUpdates = true;

SPListTemplateCollection lstTemp = oSPsite.GetCustomListTemplates(oSPWeb);

SPListTemplate template = lstTemp[strTemplateName];

oSPWeb.Lists.Add(txtListName.Text, "Description", template);

Guid listId = oSPWeb.Lists.Add(txtListName.Text, "Description", template);

SPList mylist = oSPWeb.Lists[listId];

mylist.OnQuickLaunch = false;

mylist.Update();

oSPWeb.AllowUnsafeUpdates = false;

}

oSPsite.AllowUnsafeUpdates = false;

}

});

}