Create a new Link list with pre-populated list items as a feature-based solution.
2. In the next dialog box, Select either Farm solution or Sandboxed solution whichever applicable to your requirements. I’ve selected “Deploy as a Farm Solution”
3. Right click the Project in visual studio solution explorer >> Add >> New Item >> List Instance to create new SharePoint 2010 list using visual studio
4. Enter the List Instance settings: Link List Name, List to Instantiate, URL. Click Finish.
5. Now our project will look like the below screen. Look at the “FeatureId” attribute. This is the Feature ID of the Link List feature. In case, If you want to create a List instance for your own List definition, You can use the Feature ID of the particular List. (You can just get into 14 Hive, Templates and pick the relevant feature folder’s Feature.xml file to get the feature Id)
6. Rename the Feature from “Feature1” to “DashboardLinks” in solution explorer. Get into the Feature designer (Right click the “DashboardLinks” and choose “View Designer”), Give it a meaning full title (Here I’ve given “Dashboard Links Feature”) that will appear on the site features page. Add the DashboardLinks ListInstance Element to the feature.
7. Our requirement is to Pre-populate the Dashboard Links list. So, let’s add the <Data> element with values to the Elements.xml as below:
SharePoint 2010 list instance elements.xml
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <ListInstance Title="Dashboard Links" OnQuickLaunch="TRUE" TemplateType="103" FeatureId="00bfea71-2062-426c-90bf-714c59600103" Url="Lists/DashboardLinks" Description=""> <Data> <Rows> <Row> <Field Name="URL">http://Crescent.SharePoint.com/sites/PMO/Dashboard, PMO Dashboard</Field> <Field Name="Comments">PMO Dashboard Link</Field> </Row> <Row> <Field Name="URL">http://Crescent.SharePoint.com/sites/functional/Dashboard, Functional Dashboard</Field> <Field Name="Comments">Functional Dashboard Link</Field> </Row> <Row> <Field Name="URL">http://Crescent.SharePoint.com/sites/operations/Dashboard, Operational Dashboard</Field> <Field Name="Comments">Operations Dashboard Link</Field> </Row> </Rows> </Data> </ListInstance> </Elements>
8. Build and deploy the Project (Just right click the Project in visual studio, choose Build and then choose Deploy)
9. Verify the feature is activated by going to Site actions >> Site settings >> Manage Site features (Under Site actions tab)
10. See it in action! List created in SharePoint using Visual Studio 2010 feature.