SharePoint – How to use the Inbuilt Data View Webpart to Display and Perform CRUD Operations on a List
Posted by: Ravi Keshwani
in Category SharePoint
Abstract: In this article, we will explore how we can use the very useful Data View web part to customize list data and perform CRUD operations on it.
In this article, we will explore how we can use the very useful Data View web part to customize list data and perform CRUD operations on it.
Taking a real life example, we will show the name of the teams in a Grid like format (in a list), where members of a team are added. So create 2 lists named ‘Team’ where name of the teams are added and second ‘Members’ where team will be a lookup column.
So assuming you have created these 2 lists, let us move ahead to implement our requirement. Follow these steps:
Step 1: Open your site in SharePoint designer.
Step 2: From the ‘Folder list’ to the left, drilldown the ‘Lists’ folder and open ‘Members’ list. The screen would be as shown below. Double click on AllItems.aspx
Step 3: Now click on split view in the form designer and find the string ‘PlaceHolderMain’. Place the cursor in the next line.
Step 4: Now click on Insert > Sharepoint Controls > Data View
Step 5: This will add a Webpart, which will show some guidelines of what to do next with it, as shown below
Step 6: Clicking on the link ‘Click a data source in the…’ will open a Data Source library which will have SharePoint lists. Click on the list named ‘Teams’ and right click on it and then click ‘Show Data’, as shown below.
Step 7: Clicking on ‘Show Data’ will display the columns belonging to this list. Press the ‘Ctrl’ key and select the columns you want to insert into the data view and click on ‘Insert Selected fields as’ button, above the columns list.
Step 8: Now this will insert fields in the web part. Right click on the web part and click on ‘Show Common Control Tasks’ which will provide options to customize the web part as per our needs. This is similar to customizing the Grid in ASP.NET
Step 9: Click on Data View properties from this properties window and using it, check the checkbox ‘Show toolbar with options for’ in the General tab and check the options of Filter, Sort and Grouping.
Step 10: Also to make CRUD operations active, go to the Editing tab of the popup and click on required operations, as shown below.
Refresh the page in your SharePoint website, which is currently showing the members list and see the magic. The output will be similar to the one show below.