Monday, August 24, 2009

Create a Data View by using the Data Source Details task pane

When you create a Data View by using the Data Source Details task pane, you first insert a Data View into the page. You then select a data source in the Data Source Library, a task pane that manages available data sources for a SharePoint site. After you select your data source, the Data Source Details task pane opens. In the Data Source Details task pane, you choose the fields that you want to display and then insert them into the Data View.

Data Views are based on ASP.NET 2.0 technology. To create a Data View, you must start with an ASP.NET page (.aspx file). In this example, you will create a new ASP.NET page, and then create a Data View by using the Data Source Details task pane.

  1. On the File menu, click New.
  2. In the New dialog box, double-click ASPX.

    A new page with a FORM tag opens.

    An ASP.NET form tag appears on the page.

  3. On the Data View menu, click Insert Data View.

    An empty Data View is now displayed on the page, and the Data Source Library task pane opens.

    An empty Data View Web Part

    Now that you have inserted the Data View, you are ready to add data.

  4. In the Data Source Library task pane, locate your data source, click it, and then click Show Data.

    In the example, under XML Files, click products.xml, and then click Show Data. If the XML Files heading is collapsed, click the plus sign (+) to expand it.

  5. In the Data Source Details task pane, click the fields that you want to insert in the Data View.

    TIP To select multiple fields, hold down CTRL while you click them.

    In the example, in the ProductsRoot folder, under Products, clickProductName. Press and hold down CTRL while you click UnitsInStock,UnitsOnOrder, and ReorderLevel.

    Fields selected in the Data Source Details task pane

  6. Click Insert Selected Fields as, and then click Multiple Item View to insert the selected data into the Data View.

    NOTE Single Item View displays a single record in a Data View. Multiple Item View displays multiple records, with the fields in columns with headings for each column.

    The fields that you selected in the Data Source Details task pane now appear in a table.

    Products.xml as it appears in a Data View

  7. After you create a Data View, you can use WYSIWIG tools such as the Formattingtoolbar to modify fonts, align text, or apply colors. When you apply new formatting to a data point in your Data View, Office SharePoint Designer 2007 applies the formatting to all of the data at the same level in the XML by modifying the XSLT style sheet attached to the page. For example, in the previous illustration, if you select Chai and then click Bold on the Formatting toolbar, Office SharePoint Designer 2007 applies the same formatting to all of the content that appears in the ProductName field.

    Bold formatting applied to all data in the ProductName field

No comments: