Use XML Files to Drive Your Navigation Menu
How to Set SharePoint 2010 Page Layout Defaults
Add Content to Pages via SharePoint 2010's Publishing Site

Create a SharePoint 2010 Web Part from Scratch

Sometimes, you may want to create a simple one-off Web Part that isn’t tied to any of the styles provided by the Content Query Web Part in SharePoint 2010. In those cases, you might want to use the Data Form Web Part. (You may not have worked with the Data Form Web Part before because it requires SharePoint Designer.)

This Web Part is often referred to as the Swiss Army Knife of Web Parts because it’s extremely versatile.

Even if your company doesn’t allow you to connect to their production SharePoint farm with SharePoint Designer, you can still use the Data Form Web Part. You can configure the Web Part with another instance of SharePoint, say, on your laptop or in a lab, and then import the Web Part into your production site.

To insert a Data Form Web Part, follow these steps:

  1. Open a new Web Part page in SharePoint Designer 2010.

    You can either create your Web Part page in the browser and open it in SharePoint Designer, or you can use SharePoint Designer to create the new Web Part page for you.

  2. Click the Design tab to view your Web Part page in Design mode.

  3. On the Insert tab, click the Data View button and choose Empty Data View.

    SharePoint Designer inserts a new Web Part on the page, and a new set of tabs appears in the Ribbon.

    image0.jpg

After you insert the Web Part, your next steps are to select the data source, add your columns, and apply sorting, filtering, and conditional formatting as desired.

To select your data source:

  1. Inside the Web Part, click the Click Here to Select a Data Source link.

    The data sources picker appears.

  2. Select the list or library you want to display in your Web Part and click OK.

    The Data Source Details pane appears.

  3. Ctrl-click the columns you want to appear in your Web Part.

  4. Click the Insert Selected Fields As drop-down list and then choose an option to display the content.

    You have several options:

    • Single Item View or Multiple Item View: Inserts the selected fields so that the Web Part displays one item at a time or several rows at once, respectively.

    • Single Item Form or Multiple Item Form: Displays a data entry form using the field(s) you select.

    • New Item Form: Displays a form for entering new items into your data source.

      image1.jpg

You can create very complex data sources that query other sites and even join two lists. SharePoint uses its own query language, CAML. SharePoint Designer generates the CAML query for you, but you can also insert your own query.

Here is a Data Form Web Part with Multiple Item View selected. When you have your data source inserted, the Ribbon activates the commands you can use, which you can also see.

image2.jpg

Use the Design tab on the Ribbon to change the layout of the items in your Web Part. SharePoint Designer provides several built-in formats.

Many of these formatting options also apply to the views you create for lists and libraries. For example, you can use conditional formatting with a list view.

image3.jpg

When the Data Form Web Part queries SharePoint, the data is returned as an XML document. XML documents have their own set of languages, XSL and XPath, that can be used to filter the data and display it exactly as you want.

By viewing your Data Form Web Part in Code View using the View tab on the Ribbon in SharePoint Designer, you can view the XSL generated by SharePoint Designer. You can edit this XSL to display your data virtually any way you please.

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
How to Work with Content Placeholders in SharePoint 2010
How to Add a Summary Link Web Part
Open a SharePoint 2010 Page Layout for Editing
Set Up an Approval Workflow in SharePoint 2010
Turn on Content Approval for SharePoint 2010 Sites
Advertisement

Inside Dummies.com