Rick Kierner posted on December 11, 2008 18:32

If you are creating a list with code, you'd do it like this:

   1: SPWeb web = properties.Feature.Parent as SPWeb;
   2: if (web != null)
   3: {
   4:     //create List
   5:     SPListTemplate template = null;
   6:     try
   7:     {
   8:         template = web.ListTemplates["Custom List"];
   9:     }
  10:     catch
  11:     {
  12:         throw new Exception("In ListTemplate 'Custom List' Retrieval", ex);
  13:     }
  14:     if (template != null)
  15:     {
  16:         Guid id = web.Lists.Add("My List Name", "My List Description", template);
  17:         web.Update();
  18:     }
  19:     else
  20:     {
  21:         throw new Exception(message);
  22:     }
  23: }

 

To determine what your list template name would be here are your choices:

  • Document Library
  • Form Library
  • Wiki Page Library
  • Picture Library
  • Links;Announcements
  • Contacts
  • Calendar
  • Discussion Board
  • Tasks
  • Project Tasks
  • Issue Tracking
  • Custom List
  • Custom List in Datasheet View
  • Survey
  • No Code Workflows
  • DataSources
  • Custom Workflow Process
  • Workflow History;

Posted in:   Tags: ,
Comments are closed
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012 Rick.Brain.Flush()