Problem
We had to add couple items to SharePoint list declaratively. So that when we deploy the solution, SharePoint list and the default items will be provisioned in SharePoint site.
Solution
Step 01:
Add a SharePoint list to Visual Studio.
Step 02:
Open the Elements.xml file of list instance.
So you will see something like this.
Step 03:
Add the data.
- <?xml version="1.0" encoding="utf-8"?>
- <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
- <ListInstance Title="List1"
- OnQuickLaunch="TRUE"
- TemplateType="10000"
- Url="Lists/List1"
- Description="My List Instance">
- <Data>
- <Rows>
- <Row>
- <Field Name="Title">Item 001</Field>
- </Row>
- <Row>
- <Field Name="Title">Item 002</Field>
- </Row>
- </Rows>
- </Data>
- </ListInstance>
- </Elements>
Here the Name in the field will be column name.
Conclusion
Right click and deploy. Then open the list in the browser and you can see the items.
You can download the basic sample solution from the below link.
https://drive.google.com/file/d/0ByEnOE8DAdvhVjB4RVkxUk9CcWM/edit?usp=sharing
No comments:
Post a Comment