Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 0.76 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Need help in SharePoint list.
  2. using (SPSite oSPsite = new SPSite("http://Web URL"))
  3. {
  4.     oSPsite.AllowUnsafeUpdates = true;
  5.  
  6.     using (SPWeb oSPWeb = oSPsite.OpenWeb())
  7.     {
  8.         oSPWeb.AllowUnsafeUpdates = true;
  9.  
  10.         /* 1. create list from custom ListTemplate present within ListTemplateGalery */
  11.         SPListTemplateCollection lstTemp = oSPsite.GetCustomListTemplates(oSPWeb);
  12.         SPListTemplate template = lstTemp["custom template name"];
  13.         oSPWeb.Lists.Add("List Name", "Description", template);
  14.  
  15.         /* 2. create list from sharepoint list content type (e.g. Links) */
  16.         oSPWeb.Lists.Add("List Name", "Description", SPListTemplateType.Links);
  17.         oSPWeb.AllowUnsafeUpdates = false;
  18.     }
  19.     oSPsite.AllowUnsafeUpdates = false;
  20. }