You can use filter Web Parts to pass values to the Data View Web Part, and then change the view of data in the list based on the value. For example, you can select from a list of product orders in a Choice Filter Web Part, and then simultaneously display the products that correspond to that order in a Data View Web Part.

What do you want to do?

Learn about connecting the Filter Web Parts to the Data View Web Part

This section discusses the ways you can filter a Data View Web Part, and best practices when you design and edit a Web Part page containing filter Web Parts and Data View Web Part connections.

How filter Web Parts work

In general, connecting a filter Web Part to a Data View Web Part works in the following way:

Overview of connecting a filter Web Part

1. Connect a filter Web Part to a Data View Web Part to display a subset of data.

2.  The filter Web Part provides a value.

3. The filter value is passed to a column in the Data View Web Part by using a Web Part connection.

4. The Data View Web Part displays only those columns that match the filter value.

Ways to filter a Data View Web Part

You can connect filter Web Parts to a Data View Web Part so that a user can filter items based on a value in a column in the following ways:

  • Text filter     A text value that can be any string, including letters, characters, and numbers.

  • Date filter    A date value of month, day, and year. A user can also enter the exact date by clicking a date picker button.

  • Choice filter     A predefined list of values and optional descriptions, such as product or status codes.

  • Current user     The current user name, or other information based on the current user's SharePoint profile, such as user name, department, or birthday. This Web Part is a context Web Part, which means that is not visible to a user on the Web Part Page and the results display automatically without user input.

  • SharePoint list    A list of unique values and optional descriptions, such as product or status codes, generated from a column in a SharePoint list. This Web Part is similar in behavior to the Choice Filter Web Part, and is useful when you have a list of values that might change overtime and you want an easier way to maintain the list without having to change the Web Part properties.

You can make two or more connections at a time to a Data View Web Part by making a different connection to the same Data View Web Part from each filter Web Part.

Best practices for designing and maintaining Web Part Pages

Here are a few best practices to follow as you design and maintain Web Part Pages:

  • Choose your Web Part Page template carefully    You can move Web Parts around on a Web Part Page to place them in any order and in any Web Part zone that you want. However, before you create a Web Part Page, think carefully about the template that you choose so that you can lay out the filter and List View Web Parts the way you want. When using a Web browser, you cannot change the template that you selected after you created the Web Part Page. If you have a Web design program such as Microsoft Office SharePoint Designer 2007, you can further change the structure of the Web Part Page.

  • Remove connections to disabled Web Part properties    In page edit mode, you can see which filter Web Parts are currently connected and how they are connected by a message that is displayed underneath the filter Web Part.

    In some cases, you may need to remove the connection to make a change to a disabled filter Web Part property. If this is the case, in the tool pane you see the following message to remind you:

    "You must remove the connection between the Web Parts to make changes to disabled properties."

  • Remove unused Web Parts from the Web Part Page    If you inadvertently close a Web Part, rather than delete it, the Web Part remains on the page as a hidden Web Part. To find hidden Web Parts, find the Web Part Page in the document library in which it is stored, point to the file name of the Web Part, click the arrow that appears, click Edit Properties, and then click the Open Web Part Page in maintenance view link. For more information about maintaining Web Parts, see Customize Web Parts.

Top of Page

Connect a Text Filter Web Part to a Data View Web Part

The following procedure assumes you are creating a Web Part Page on a team site. Commands and instructions can vary on other sites.

Prepare the Web Part Page:    

  1. Do one of the following:

    • To create a Web Part Page, on the Site Actions menu Button image, click Create, and then click Web Part Page.

      For more information, see Introduction to customizing pages by using Web Parts.

    • To edit the Web Part Page, click Site Actions Button image, and then click Edit Page.

      The Web Part Page is displayed in Edit Mode.

  2. In the Web Part zone where you want to add the Web Part, click Add a Web Part.

    The Add Web Parts dialog box appears.

  3. Add the Text Filter Web Part to the Web Part Page.

    For more information about how to add a Web Part, see Add or remove a Web Part.

    Customize the Text Filter Web Part:    

  4. In the Text Filter Web Part, click the Open the tool pane link.

    The Text Filter Web Part enters Edit Mode, and the Web Part tool pane appears.

  5. Edit the custom Web Part properties by doing the following:

    1. Enter a name in the Filter Name box to identify the Web Part.

      You can also use the name as a label or brief instruction to the user. For example, you can use Filter Reports By: as a label to tell users they can filter the view of a Reports list.

    2. Optionally, in the Advanced Filter Options section, do one or more of the following:

      • To limit the number of characters, enter the number in the Maximum number of characters text box. The maximum length of a text value is 255 characters.

      • To enter an initial value in the Text Filter Web Part text box, enter a default value in the Default Value box, a value that typically matches one of the values entered in step 2 of 5. This default value is then used to display the initial list of values in the Data View Web Part when the Web Part Page first displays.

      • To display a message that reminds the user to make a choice to filter the data, select the Require user to choose a value check box.

      • In the Control width in pixels. text box, enter a number indicating the width of the Text Filter Web Part text box as the number of pixels, or an empty value or "0" to automatically size the text box. Because the value entered by the user displays in this text box, you probably want to make it wide enough for the largest possible value.

    3. To save the changes, click OK at the bottom of the Web Part tool pane.

      Create and customize the Data View Web Part:    

  1. Create and customize the Data View Web Part in Microsoft Office SharePoint Designer 2007.

    For more information, see Create a Data View.

    Connect both Web Parts and verify the results:    

  2. Do one of the following:

    1. In the Web browser, do the following:

      1. Click the Web Part menu Web Part menufor the Text Filter Web Part, point to Connections, point to Send Filter Values To, and then click the name of the Data View Web Part to which you want to link.

      2. Click Configure, select the column that you want to filter in the Data View Web Part from the list box, and then click Finish.

      3. To exit Web Part Page Edit Mode and view the page, at the top of the Web Part Page, under the Site Actions Button imagemenu, click Exit Edit Mode.

    2. In Office SharePoint Designer 2007, connect the Web Parts, and then preview the Web Part Page.

      For more information, see Connect two Data Views.

  3. To dynamically change the workbook results in the Data View Web Part, in the Text Filter Web Part, enter some text in the text box that exactly matches a value in the column in the Data View Web Part specified in the connection you made in step 10, and then click OK.

    Note: The Text Filter Web Part does not recognize wildcard characters. If a user enters a wildcard character, such as an asterisk (*) or a percent sign (%), the character is interpreted as a literal character.

    To redisplay all the values in the Data View Web Part, the user must clear the text box, and then press ENTER.

Top of Page

Connect a Date Filter Web Part to a Data View Web Part

The following procedure assumes you are creating a Web Part Page on a team site. Commands and instructions can vary on other sites.

Prepare the Web Part Page:    

  1. Do one of the following:

    • To create a Web Part Page, on the Site Actions menu Button image, click Create, and then click Web Part Page.

      For more information, see Introduction to customizing pages by using Web Parts.

    • To edit the Web Part Page, click Site Actions Button image, and then click Edit Page.

      The Web Part Page is displayed in Edit Mode.

  2. In the Web Part zone that you want to add the Web Part to, click Add a Web Part.

    The Add Web Parts dialog box displays.

  3. Add the Date Filter Web Part to the Web Part Page.

    For more information, see Add or remove a Web Part.

    Customize the Date Filter Web Part:    

  4. In the Date Filter Web Part, click the link, Open the tool pane.

    The Date Filter Web Part enters Edit Mode, and the Web Part tool pane is displayed.

  5. Edit the custom Web Part properties by doing the following:

    1. Enter a name in the Filter Name box to identify the Web Part.

      You can also use the name as a label or brief instruction to the user. For example, you can use Filter Reports By: as a label to tell users they can filter the view of a Reports list.

    2. To enter an initial value in the Date Filter Web Part text box, select Default Value, and then do one of the following:

      • Select Specific Date, and then enter a specific date.

      • Select Offset from today, and then enter the number of days in the Days text box. The maximum value is 999.

        This default value is then used to display the initial list of values in the Data View Web Part when the Web Part Page first displays.

    3. Optionally, under the Advanced Filter Options section, to display a message that reminds the user to make a choice to filter the data, select the Require user to choose a value check box.

    4. To save the changes, click OK at the bottom of the Web Part tool pane.

      Create and customize the Data View Web Part:    

  1. Create and customize the Data View Web Part in Microsoft Office 2007 SharePoint Designer.

    For more information, see Create a Data View.

    Connect both Web Parts and verify the results:    

  2. Do one of the following:

    1. In the Web browser, do the following:

      1. Click the Web Part menu Web Part menufor the Date Filter Web Part, point to Connections, point to Send Filter Values To, and then click the name of the Data View Web Part to which you want to link.

      2. Click Configure, select the column you want to filter in the Data View Web Part from the list box, and then click Finish.

      3. To exit Web Part Page Edit Mode and view the page, at the top of the Web Part Page, under the Site Actions Button imagedrop-down menu, click Exit Edit Mode.

    2. In Office SharePoint Designer 2007, connect the Web Parts, and then preview the Web Part Page.

      For more information, see Connect two Data Views.

  3. To dynamically change the workbook results in the Data View Web Part, in the Date Filter Web Part, enter a date or click the Date picker button, and then click OK. The value must match exactly a value in the column in the Data View Web Part specified in the connection you made in step 10.

    A user needs to enter the date in the short date format for the current regional setting used by the SharePoint site, which can vary depending on your computer or server site's regional setting. For example, for English (United States) use mm/dd/yyyy, and for French (France) use dd/mm/yyyy. The user can also use the date picker to ensure the correct date entry.

    To redisplay all the values in the Data View Web Part, the user must clear the date from the text box, and then press ENTER.

Top of Page

Connect a Choice Filter Web Part to a Data View Web Part

The following procedure assumes you are creating a Web Part Page on a team site. Commands and instructions can vary on other sites.

Prepare the Web Part Page:    

  1. Do one of the following:

    • To create a Web Part Page, on the Site Actions menu Button image, click Create, and then click Web Part Page.

      For more information, see Introduction to customizing pages by using Web Parts.

    • To edit the Web Part Page, click Site Actions Button image, and then click Edit Page.

      The Web Part Page is displayed in Edit Mode.

  2. In the Web Part zone that you want to add the Web Part to, click Add a Web Part.

    The Add Web Parts dialog box displays.

  3. Add the Choice Filter Web Part to the Web Part Page.

    For more information, see Add or remove a Web Part.

    Customize the Choice Filter Web Part:    

  4. In the Choice Filter Web Part, click the link, Open the tool pane.

    The Choice Filter Web Part enters Edit Mode, and the Web Part tool pane is displayed.

  5. Do the following:

    1. Enter a name in the Filter Name box to identify the Web Part.

      You can also use the name as a label or brief instruction to the user. For example, you can use Filter Reports By: as a label to tell users they can filter the view of a Reports list.

    2. Enter the list of values and an optional description that you want a user to be able to select in the Select Filter Value(s) dialog box which displays when a user clicks the Filter Applied filter iconbutton. For example, if you have a list of customers with a Status column, you can enter Standard, Preferred, and Elite as the list of values, each value on a separate line. These values are used to match Status column values in the Data View Web Part that a user would enter in step 10.

      For each value on each line, you can also add an alternative description that displays in the Select Filter Value(s) dialog box instead of the values when the user filters the data. For example:

      Standard; A regular customer with an average credit ratingPreferred; A regular customer with a high credit ratingElite; A high-volume customer with a high credit rating

      Note: The list of choices must contain at least one choice and must be unique. Neither value nor description may exceed 255 characters in length. The maximum number of choices is 1000.

    3. Optionally, under the Advanced Filter Options section, do one or more of the following:

      • In the Control width in pixels. text box, enter a number indicating the width of the choice text box as the number of pixels, or an empty value or "0" to automatically size the Choice Filter Web Part text box. Because the value entered by the user displays in this text box, you probably want to make it wide enough for the largest possible value.

      • To display a message that reminds the user to make a choice to filter the data, select the Require user to choose a value check box.

      • To enter an initial value in the Choice Filter Web Part text box, enter a default value in the Default Value box, a value that typically matches one of the values entered in step 2 of step 5. This default value is then used to display the initial list of values in the Data View Web Part when the Web Part Page first displays.

      • To enable users to filter by a null value, select "(Empty)" value. For example, users may want to see all customers with no status defined.

      • To enable clearing of a filter so users can see all the values in the Data View Web Part, select Allow Multiple selections. In this case, the Select Filter Value(s) dialog box displays check boxes, and not radio buttons.

        Note: You cannot use this feature to display the filtered results of two or more selections, because The Data View Web Part does not support multiple selections. If a user chooses multiple selections, only the first selection is used.

    4. To save the changes, click OK at the bottom of the Web Part tool pane.

      Create and customize the Data View Web Part:    

  1. Create and customize the Data View Web Part in Microsoft Office 2007 SharePoint Designer.

    For more information, see Create a Data View.

    Connect both Web Parts and verify the results:    

  2. Do one of the following:

    1. In the Web browser, do the following:

      1. Click the Web Part menu Web Part menufor the Choice Filter Web Part, point to Connections, point to Send Filter Values To, and then click the name of the Data View Web Part to which you want to link.

      2. Click Configure, select the column you want to filter in the Data View Web Part from the list box, and then click Finish.

      3. To exit Web Part Page Edit Mode and view the page, at the top of the Web Part Page, under the Site Actions Button imagedrop-down menu, click Exit Edit Mode.

    2. In Office SharePoint Designer 2007, connect the Web Parts, and then preview the Web Part Page.

      For more information, see Connect two Data Views.

  3. To dynamically change the workbook results in the Data View Web Part, in the Choice Filter Web Part, click Filter Applied filter icon, click a value, and then click OK.

    If you selected the Allow Multiple selections property, to redisplay all the values in the Data View Web Part, the user must clear all the check boxes in the Select Filter Value(s) dialog box, and then click OK.

Top of Page

Connect a Current User Filter Web Part to a Data View Web Part

The following procedure assumes you are creating a Web Part Page on a team site. Commands and instructions can vary on other sites.

Prepare the Web Part Page:    

  1. Do one of the following:

    • To create a Web Part Page, on the Site Actions menu Button image, click Create, and then click Web Part Page.

      For more information, see Introduction to customizing pages by using Web Parts.

    • To edit the Web Part Page, click Site Actions Button image, and then click Edit Page.

      The Web Part Page is displayed in Edit Mode.

  2. In the Web Part zone that you want to add the Web Part to, click Add a Web Part.

    The Add Web Parts dialog box displays.

  3. Add the Current User Filter Web Part to the Web Part Page.

    For more information, see Add or remove a Web Part.

    Customize the Current User Filter Web Part:    

  4. In the Current User Filter Web Part, click the link, Open the tool pane.

    The Current User Filter Web Part enters Edit Mode, and the Web Part tool pane is displayed.

  5. Edit the custom Web Part properties by doing the following:

    1. Enter a name in the Filter Name box to identify the Web Part.

    2. Under the Select value to provide section, do one of the following:

      • To filter by the user name, select Current user name.

      • To filter by another value in the current user's SharePoint profile, select SharePoint profile value for current user, and the select an item from the list box.

        The list box is populated with the list of all SharePoint profile properties that have a privacy policy of Everyone.

        An easy way to see a list of user profiles at your site is to display the MyProfile tab on My Site, and then edit the details.

    3. Optionally, under the Advanced Filter Options section, do one or more of the following:

      • To enable users to filter by a null value, select Send empty if there are no values. For example, you may want to see if a profile value for that user is not entered in the column.

      • To decide how to handle more than one value, under When handling multiple values, do one of the following:

        • To pass only one value by using the Web Part connection, select Send only the first value.

        • To pass two or more values by using the Web Part connection, select Send all values.

        • To pass two or more delimited values by using the Web Part connection, select Combine them into a single value and delimit with, and then enter one or more characters in the text box.

      • To prefix a value to the Web Part property value to ensure a match to the column in the SharePoint list, enter text in the Text to insert before values text box. .

      • To post-fix a value to the Web Part property value to ensure a match to the column in the SharePoint list, enter text in the Text to insert after values.

    4. To save the changes, click OK at the bottom of the Web Part tool pane.

      Create and customize the Data View Web Part:    

  1. Create and customize the Data View Web Part in Microsoft Office 2007 SharePoint Designer.

    For more information, see Create a Data View.

    Connect both Web Parts and verify the results:    

  2. Do one of the following:

    1. In the Web browser, do the following:

      1. Click the Web Part menu Web Part menufor the User Filter Web Part, point to Connections, point to Send Filter Values To, and then click the name of the Data View Web Part to which you want to link.

      2. Click Configure, select the column you want to filter in the Data View Web Part from the list box, and then click Finish.

      3. To exit Web Part Page Edit Mode and view the page, at the top of the Web Part Page, under the Site Actions Button imagedrop-down menu, click Exit Edit Mode.

    2. In Office SharePoint Designer 2007, connect the Web Parts, and then preview the Web Part Page.

      For more information, see Connect two Data Views.

  3. To dynamically change the workbook results in the Data View Web Part, display the Web Part Page. Because the Current User Filter Web Part is a context Web Part, the results display automatically without user input.

Top of Page

Connect a SharePoint List Filter Web Part to a Data View Web Part

The following procedure assumes you are creating a Web Part Page on a team site. Commands and instructions can vary on other sites.

Prepare the Web Part Page:    

  1. Do one of the following:

    • To create a Web Part Page, on the Site Actions menu Button image, click Create, and then click Web Part Page.

      For more information, see Introduction to customizing pages by using Web Parts.

    • To edit the Web Part Page, click Site Actions Button image, and then click Edit Page.

      The Web Part Page is displayed in Edit Mode.

  2. In the Web Part zone that you want to add the Web Part to, click Add a Web Part.

    The Add Web Parts dialog box displays.

  3. Add the SharePoint List Filter Web Part to the Web Part Page.

    For more information, see Add or remove a Web Part.

    Customize the SharePoint List Filter Web Part:    

  4. In the SharePoint List Filter Web Part, click the link, Open the tool pane.

    The SharePoint List Filter Web Part enters Edit Mode, and the Web Part tool pane is displayed.

  5. Edit the custom Web Part properties by doing the following:

    1. Enter a name in the Filter Name box to identify the Web Part.

      You can also use the name as a label or brief instruction to the user. For example, you can use Filter Reports By: as a label to tell users they can filter the view of a Reports list.

    2. To specify a SharePoint list, enter the URL of a list in the List box, or click Browse next to the text box and search for the list you want.

    3. Optionally, to select a different list view, select an item from the View list box. For example, you may want to filter, sort, or group data a different way or display different columns.

    4. Select a column from the Value field list box. The value column displays all supported columns from the list. Some columns are not supported, such as Title, Calculated, and Multiple lines of text.

      Important: When you make the connection between the SharePoint List Filter Web Part and the Data View Web Part in step 10, make sure you choose a column that has matching values to the Value field property.

      Note: A SharePoint List Filter Web Part has a limit of 100 items.

    5. Optionally, select a column from the Description field list box. The description column is used to display an alternative value in the Select Filter Value(s) dialog box, which displays when a user clicks the Filter Applied filter iconbutton. For example, if you have a Month number column that uses the numbers 1 though 12 as month values, you can use a Month Name column as the Description column so that January is displayed instead of 1, February instead of 2, and so on.

    6. Optionally, under the Advanced Filter Options section, do one or more of the following:

      • In the Control width in pixels. text box, enter a number indicating the width of the SharePoint List Web Part text box as the number of pixels, or an empty value or "0" to automatically size the SharePoint List Filter Web Part text box. Because the value entered by the user displays in this text box, you probably want to make it wide enough for the largest possible value.

      • To display a message that reminds the user to make a choice to filter the data, select the Require user to choose a value check box.

      • To enter an initial value in the SharePoint List Filter Web Part text box, enter a default value in the Default Value box, a value that typically matches one of the values in the column specified in step 4 of step 5. This default value is then used to display the initial list of values in the Data View Web Part when the Web Part Page first displays.

      • To enable users to filter by a null value, select "(Empty)" value. For example, users may want to see all values in a column that have no entry.

      • To enable clearing of a filter so users can see all the values in the Data View Web Part, select Allow Multiple selections.

        The Select Filter Value(s) dialog box displays check boxes, and not radio buttons.

        Note: A user cannot use this feature to display the filtered results of two or more selections, because The Data View Web Part does not support multiple selections. If a user chooses multiple selections, only the first selection is used.

    7. To save the changes, click OK at the bottom of the Web Part tool pane.

      Create and customize the Data View Web Part:    

  1. Create and customize the Data View Web Part in Microsoft Office 2007 SharePoint Designer.

    For more information, see Create a Data View.

    Connect both Web Parts and verify the results:    

  2. Do one of the following:

    1. In the Web browser, do the following:

      1. Click the Web Part menu Web Part menufor the SharePoint List Filter Web Part, point to Connections, point to Send Filter Values To, and then click the name of the Data View Web Part to which you want to link.

      2. Click Configure, select the column you want to filter in the Data View Web Part from the list box, and then click Finish.

      3. To exit Web Part Page Edit Mode and view the page, at the top of the Web Part Page, under the Site Actions Button imagedrop-down menu, click Exit Edit Mode.

    2. In Office SharePoint Designer 2007, connect the Web Parts, and then preview the Web Part Page.

      For more information, see Connect two Data Views.

  3. To dynamically change the workbook results in the Data View Web Part, in the SharePoint List Filter Web Part, click Filter Applied filter icon, click a value, and then click OK.

    If you selected the Allow Multiple selections property, to redisplay all the values in the Data View Web Part, the user must clear all the check boxes, and then click OK.

Top of Page

Behöver du mer hjälp?

Vill du ha fler alternativ?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.