Tuesday, July 17, 2012

Understanding Data Form Web Part in SharePoint 2010/ MOSS 2007 – Part 1

We are going to start a new series of data form web part. Data Form web part is one of the most important web part in SharePoint.

 First to start with, let me clear the difference between data form web part and data view web part because this is the most common question arises when it comes to these two web parts.

Data View web part was introduced in WSS 2.0 and Data Form web part was introduced in WSS 3.0. So obviously data form web part is advanced than data view web part. However it depends on what you want to perform.

Data view web part as name suggest only be used to view the data. However data form web part writes back the data to the source as well.

Both web parts can only be created from SharePoint Designer and not from the browser. Both still uses XSLT to transform the data into the representation form. But data form web part uses SPDataSource control to connect with source and fetch the data.

We are going to see what data form web can do.

First it can fetch data not only from SharePoint but also from SQL server, web service, and XML file.

It can also take parameters to display data in it. Parameters can come from query string, it can also be cookie, and it can also be form fields.

So connect with your site via SharePoint Designer. Open a page where you want to add data form web part.

I have one list in site.



Now keep the cursor inside place holder and click on data view and then click on Stock Item colors list.



Once you add it, you get something like this.



At this point of time, just save the file and open the page in browser.



Now go back to designer and select three fields by holding ctrl key and then click on Insert selected field drop down and select multiple items view and you’ll get this.



Again save and check it in browser.



Now let’s go ahead and select the data form web part. Look at the ribbon and you see you can configure different options like group, sorting, filtering and parameters.

Let’s click on sorting option.



Sort by color in ascending order



You can also click on show group header option and you get something like this



Save it and view in the browser.

Now we are going to add parameters. So go back to designer and click on parameters option. By default you will see these two parameters.



Go ahead and click on New Parameter and select type as query string. As you can see you have difference option to define the source of this parameter.



Now we have parameter so we now need to configure the filter based on this parameter.
Select data form web part and then click on filter. Then select color as field and set it like this.



Once set you’ll get this in designer. It does not show any data because there are no colors defined now.



Click on sample data in design tab.



Save the page and open the page in browser.

Initially you will see no data. Pass the parameter and value to see data in the web part.




Continue reading Part -2 for further understanding.

No comments:

Post a Comment