Changing the Location Attribute for the ParameterBindings Element of the Data View Web Part in FrontPage 2003

 

Lisa Wollin
Microsoft Corporation

September 2004

Applies to:
    Microsoft Office FrontPage 2003
    Microsoft Windows SharePoint Services

Summary:   Using the Data View Web Part in Microsoft Office FrontPage 2003, you can create custom data views for pages on SharePoint sites. Learn how you can use the Location attribute of the ParameterBinding element for a Data View Web Part to create custom filters and change the location from which the resulting data is accessed. (5 printed pages)

Contents

Introduction
Getting Started
Understanding Location Attribute Values
Changing the Parameter Value
Conclusion

Introduction

If you work with Web sites based on Microsoft Windows SharePoint Services, called SharePoint sites, or develop custom Web Parts to display custom sets of data, the Data View Web Part, which is available only from within Microsoft Office FrontPage 2003, might be the best and quickest way to create custom views.

The Location attribute for the ParameterBinding element of the Data View Web Part allows you to specify where the data comes from. For example, you might want to determine the current user, or perhaps you need to retrieve a built-in value from Windows SharePoint Services. You can modify the Location attribute to specify that the data for a field should come from somewhere other than the default location. This article describes these and other possible values for the Location attribute.

Getting Started

To demonstrate, you need to create a test page. You can use this page to see how you can modify the default view of the Data View Web Part to display custom sets of data.

Important   Because the Data View Web Part is available only SharePoint sites, you need a SharePoint site to complete these steps.

Note   The following steps use the Task list that is part of Web sites based on Windows SharePoint Services. The Tasks list is used as an example and provides an easy source of data for this article. You can use the Data View Web Part with any data source that you use in your Web site and the following steps work for any of these data sources.

  1. Open a SharePoint site.

  2. If you do not already have a Task list set up, add the following three items to the default Task list that was created when you first set up the SharePoint site. Assign tasks 2 and 3 to yourself.

    • Item 1:
      Title: Send Joe's article for tech review
      Assigned to: (none)
    • Item 2:
      Title: Schedule September articles
      **Assigned to:**your name
    • Item 3:
      Title: Contact designer about artwork for August feature
      **Assigned to:**your name
  3. Open the SharePoint site in FrontPage by choosing Edit with Microsoft Office FrontPage from the Microsoft Internet Explorer toolbar.

  4. In FrontPage, close any pages that were opened when FrontPage started.

  5. Create a blank page.

  6. Switch to Design view, if necessary. (On the tabs below the page window, click Design.)

    Note   You cannot add a Data View Web Part to the page using the method shown in these steps in any view other than Design view. Performing the same steps in Code view produces different results. You can view the page in Split view if you drag the Data View Web Part to the page design surface and not the code window.

  7. Display the list of folders in the site, if necessary. To do so, on the View menu, click Folder List.

  8. In the Folder List, expand the Lists folder.

  9. Click and drag the Tasks folder to the design surface for the new blank page. It may take a few minutes for the page to display the tasks data.

  10. Save the new page as LocationTest.aspx.

When you are finished inserting the Data View Web Part, switch to Code view and look at the code that FrontPage generates for the Web Part, which is similar to the following code (the ellipsis indicates code removed to save space):

<dvwp:ParamBindings><![CDATA[
    <ParameterBindings xmlns="http://schemas.microsoft.com/office/fpddw">
        <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
        ...
    </ParameterBindings>]]>
</dvwp:ParamBindings>

Each one of the ParameterBinding elements contains a Location attribute that Windows SharePoint Services uses to determine the source of the data. By default, the value of the Location attribute for most ParameterBinding elements is "Postback;Connection". This value has two meanings. First, that the data is preserved through subsequent refreshes if the returned data has too many items to fit in the page and the user must use the Next button to page through subsequent records included in the dataset, or if the user posts back to the page for sorting, grouping or filtering a Data View Web Part. Second, that the data can be provided using the Web Part Connections Framework. The two exceptions are the user ID (name=UserID) and the date (name=Today), both of which use "CAMLVariable" as their location values, which means that they pull their data from a variable stored within Windows SharePoint Services. These and other possible values are explained in detail in the following section.

Understanding Location Attribute Values

The Location attribute provides six values from which you can choose. The following table lists the possible values for the Location attribute. The value of the Location attribute is a semicolon-delimited String. You can add any of these values to the default value.

Location value Description
CAMLVariable Specifies that the value comes from a variable within the CAML code in Windows SharePoint Services. For a list of possible CAML variables, see the Microsoft SharePoint Products and Technologies 2003 Software Development Kit.
Connection Specifies that the value can come from other web parts using the Web Part Connection framework.
PostBack Specifies that the parameter can be used when the page is posted and that the value should remain through subsequent page refreshes. An example of this behavior is when a Data View Web Part is paged to display only a certain number of items at a time and the returned data includes more items than are allowed in the list, requiring multiple pages.
QueryString Specifies that the value comes from a custom query appended to the URL for the page. The format is QueryString(query), where query is the name of the filter parameter.
ServerVariable Specifies that the value comes from a variable stored in Windows Server 2003. The format is ServerVariable(value), where value is the name of the server variable.
SSOTicket Specifies that the value comes from a single sign-on connection. With Microsoft SharePoint Portal Server 2003, a user can establish an single sign-on connection. When a user validates against this single sign-on connection, the user is assigned a credential ticket that you, as the developer, can use as a location in much the same way that you can use the LOGON_USER server variable. The format is SSOTicket(value), where value is the name of the SSOTicket.

Changing the Parameter Value

When you understand the possible values, you can start customizing the data displayed in the Data View Web Part. For example, perhaps you want only the tasks that have a specific word in their titles. To demonstrate how to change a parameters Location attribute value, you can add a custom filter to the Data View Web Part that you created previously. Use the following steps:

  1. Switch to Design view.
  2. Position the insertion point inside the Data View Web Part.
  3. In the Data menu, click Filter.
  4. In the Filter dialog box, click the text Click here to add a new clause. This action adds an empty row to the list of clauses.
  5. Click in the field name column, and select "Title" from the drop-down list.
  6. In the Comparison drop-down list, select Contains.
  7. Click in the value column, and select [Input Parameter] from the drop-down list.
  8. Click OK. In Design view, notice that no items are currently showing.

Switch to Code view and scroll down the page to the filterParam parameter binding item. By default it resembles the following code:

<ParameterBinding Name="filterParam"  Location="Postback;Connection"/>

To change the place from which the filter data is pulled, modify the Location attribute as described previously. For example, you might want to filter the resulting data according to a parameter in the page's URL. In this case, use QueryString for the Location attribute value and specify a parameter variable, as shown in the following code:

<ParameterBinding Name="filterParam" Location="Postback;Connection;QueryString(Parameter)"/>

By appending the value "QueryString(Parameter)" to the default Location attribute value of "Postback;Connection", you indicate to the Data View Web Part to filter the data according to the value of 'Parameter' in the URL. If you browse to this page and add the following to the URL, you see the tasks that have title that contains the text "article".

LocationTest.aspx?Parameter=article

Conclusion

By using the Data View Web Part in FrontPage 2003 and modifying the Location value, you can pull data from the attached data source in ways other than the built-in functionality of Windows SharePoint Services allows, thereby creating dynamic views that otherwise are impossible.