Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
SDK Documentation
Web Services
Lists Web Service
Lists Class
Lists Methods
 AddList Method
Community Content
In this section
Statistics Annotations (0)
Collapse All/Expand All Collapse All
Lists.AddList Method (Lists)
Creates a list in the current site based on the specified name, description, and list template ID.

Web Service: ListsWeb Reference: http://<Site>/_vti_bin/Lists.asmx
Visual Basic (Declaration)
<SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/AddList", RequestNamespace:="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace:="http://schemas.microsoft.com/sharepoint/soap/", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Wrapped)> _
Public Function AddList ( _
    listName As String, _
    description As String, _
    templateID As Integer _
) As XmlNode
Visual Basic (Usage)
Dim instance As Lists
Dim listName As String
Dim description As String
Dim templateID As Integer
Dim returnValue As XmlNode

returnValue = instance.AddList(listName, description, templateID)
C#
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/AddList", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
public XmlNode AddList (
    string listName,
    string description,
    int templateID
)

Parameters

listName

A string that contains the title of the list.

description

A string that contains a description for the list.

templateID

A 32-bit integer that specifies the list template to use. The following table shows possible values for the ID.

List Display Name

Type

Announcements

104

Contacts

105

Custom List

100

Custom List in Datasheet View

120

DataSources

110

Discussion Board

108

Document Library

101

Events

106

Form Library

115

Issues

1100

Links

103

Picture Library

109

Survey

102

Tasks

107

Return Value

A fragment in Collaborative Application Markup Language (CAML) in the following form that contains information about the new list and that can be assigned to a System.Xml.XmlNode object.
Xml
<List DocTemplateUrl="" DefaultViewUrl="/Site_Name/Lists/List_Name/AllItems.aspx" 
   ID="{6A823AF7-F9BD-45CB-B94E-8D37B343FB82}" Title="MyNewList" 
   Description="This was made with the AddList method" 
   ImageUrl="/_layouts/images/itgen.gif" 
   Name="{6A823AF7-F9BD-45CB-B94E-8D37B343FB82}" BaseType="0" 
   ServerTemplate="100" 
   Created="20030619 07:11:30" Modified="20030619 07:11:30" 
   LastDeleted="20030619 07:11:30" 
   Version="0" Direction="none" ThumbnailSize="0" WebImageWidth="0" 
   WebImageHeight="0" 
   Flags="4096" ItemCount="0" AnonymousPermMask="0" 
   RootFolder="Lists/MyNewList" ReadSecurity="1" 
   WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" 
   EventSinkData="" 
   EmailInsertsFolder=""
   AllowDeletion="True"
   AllowMultiResponses="False"
   EnableAttachments="True"
   EnableModeration="False"
   EnableVersioning="False"
   Hidden="False" 
   MultipleDataList="False" 
   Ordered="False"
   ShowUser="True" 
   xmlns="http://schemas.microsoft.com/sharepoint/soap/">
   <Fields>
      <Field ColName="tp_ID" ReadOnly="TRUE" Type="Counter" Name="ID" 
         PrimaryKey="TRUE" 
         DisplayName="ID" FromBaseType="TRUE" />
      <Field Type="Text" Name="Title" DisplayName="Title" 
         Required="TRUE" FromBaseType="TRUE" 
         ColName="nvarchar1" />
         ...
   </Fields>
   <RegionalSettings>
      <Language>1033</Language>
      <Locale>1033</Locale>
      <AdvanceHijri>0</AdvanceHijri>
      <CalendarType>1</CalendarType>
      <Time24>False</Time24>
      <TimeZone>480</TimeZone>
      <SortOrder>2070</SortOrder>
      <Presence>True</Presence>
   </RegionalSettings>
</List>

The following code example adds a custom list to the current site.

This example requires that a using (Visual C#) or Imports (Visual Basic) directive be included for the System.Xml namespace.

Visual Basic
Dim listService As New Web_Reference_Folder.Lists()
listService.Credentials = System.Net.CredentialCache.DefaultCredentials

Dim ndList As XmlNode = listService.AddList("List_Name", "Description", 100)

MessageBox.Show(ndList.OuterXml)
C#
Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists();
listService.Credentials= System.Net.CredentialCache.DefaultCredentials;

XmlNode ndList = listService.AddList("List_Name","Description",100);

MessageBox.Show(ndList.OuterXml);
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker