Creating a list instance from "Out of the box" predefined SharePoint lists is easy but limited. How about creating our custom list via Visual Studio .Net 2010?
List definitions and list instances that are based on those definitions are a fundamental part of Microsoft SharePoint 2010. Microsoft Visual Studio 2010 provides a project type that makes it easier to create list definitions in XML and to create list instances that are based on those definitions. In addition, tight integration with SharePoint 2010 enables you to deploy list definitions and list instances to a SharePoint site directly from Visual Studio 2010. Let's follow the below steps :
Open Visual Studio .Net 2010 > File (Menu) > New > Project :
Under Installed Templates, expand "SharePoint" and select "2010" from the left side panel. > Select "Empty SharePoint Project" from the right side panel. Type a name for your project, then click the OK button.
Type the URL of your local SharePoint site at the "What local site do you want to use for debugging?" textbox and choose "Deploy as a farm solution" (Differences between Farm & Sandbox Solutions) .
Click on the "View" menu > Solution Explorer > right-click at the created solution > Add > New Item :
Select "2010" for SharePoint under "Installed Templates" from the left side panel > select "List Definition" from the right side panel :
Keep/Edit the display name of the list definition , Select "Custom List" as the type of the list definition and check "Add a list intance for this list definition":
As seen below is our solution with the created custom list definition and added list instance.
Right click at "ListDefViaVS2010" project then select "Deploy" in order to deploy our solution to the SharePoint site then wait till we check that the output is successfully deployed:
Now let's go to the SharePoint site to check the deployed custom list definition , Click "Site Actions" menu then "View All Site Content":
As we can see below a new added list instance to our custom list definition "ListDefViaVs2010 - ListInstance1".
- Check the tip on how to Create a Custom SharePoint List Definition
- Bugs custom list definition using VS.Net 2010.
- Check out these other tips:
Last Update: 2011-09-27