Create list using object model in SharePoint

In this post we will discuss about how to create a custom list using SharePoint object model. Also you can check my previous posts on:

New to Office 365 SharePoint Online? Get Office 365 Enterprise E3 Subscription & Try out all the features

– Content Editor Web Part in SharePoint 2010

– Get all users from web application in SharePoint using PowerShell

– Check if list exists or not using TryGetList method in SharePoint 2010

You can create SharePoint list by using SharePoint server object model. Here is the code to create an employee list using the Contacts list template type.

SPWeb site = SPContext.Current.Web;

string ListTitle = “Employees”; // Title of the list

string ListDescription = “EnjoySharePoint Employees List”; //Description of the list.

Guid ListId = site.Lists.Add(ListTitle, ListDescription, SPListTemplateType.Contacts);

SPList list = site.Lists[ListId];

list.OnQuickLaunch = true; //This is to show the list in the quicklaunch.


The above code will create Employees list.

Check out Best Alternative to InfoPath -> Try Now


(Installation & Features)