Connect a Query String (URL) Filter Web Part to another Web Part

Use the Query String (URL) Filter Web Part to click a link that displays a Web Part Page and that automatically filters other Web Parts on that page. For example, you can create a Web Part Page that displays a different set of customers (Standard, Preferred, Elite, and All), each time a user clicks a different link (Display standard customers, Display preferred customer, Display elite customers and Display all customers )*.

* Links are not active and are for sample purposes only.
What do you want to do?


Learn more about the Query String (URL) Filter Web Part

The Query String (URL) Filter Web Part is a context filter that is not visible to a user on the Web Part Page and does not take user input. You can use the Query String (URL) Filter Web Part to filter data in connected Web Parts on a Web Part Page by using one or more name/value pairs in a URL query string. The URL query string is often defined and located in a link on another Web page (although the link can be on the same page). The name/value pair acts as a filter name and value to the other Web Parts on the Web Part Page, and takes precedence over any names with default values that are defined in Web Part properties or passed by using other connections on the Web Part Page.

The URL query string

After you connect the Query String (URL) Filter Web Part with another Web Part, you need to define a link that uses a query string parameter. For example:

 
1 2 3 4 5 ----------------URL------------------?<Name>=<Val> http://Fabercom/SalesData/Elites.aspx?Status=Elite
1 URL URL is a link to the Web Part Page containing the Query String (URL) Filter Web Part and one or more connected Web Parts.
2 ? The question mark character (?) begins the URL query string.
3 <Name> The name, in this example, is Status.
4 = The equal sign character (=) delimits the name from the value.
5 <Val> The value, in this example, is Elite.

If you are passing two or more name/value pairs, separate them with an ampersand character (&). For example:

 
1 2 3 ...?<Name>=<Val>&<Name>=<Val> ...?Status=Elite&Status=Preferred
1 <Name>=<Val> The first name/value pair is Status=Elite.
2 & The ampersand character (&) delimits each name/value pair.
3 <Name>=<Val> The second name/value pair is Status=Preferred.

Creating links

You can locate the link anywhere a link is supported including: a Web page, the Content Editor Web Part, the My Links Web Part, the Links list, and even the Web Part Title URL common property. Consider using the Summary Link Web Part which makes it easy to customize the links, add different styles, group and order, display tooltips, and even open the Web Part Page in a new window. It's often useful to also provide an additional link without the name/value pair to show all the data on the Web Part Page.

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 Top of Page

Connect a Query String (URL) Filter Web Part to another Web Part

 Note   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 Site Actions menu, click Create, and then click Web Part Page.

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

  • To edit an existing Web Part Page, click Site Actions Site Actions menu, and then click Edit Page.

The Web Part Page is displayed in Edit Mode.

  1. 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.

  1. Add the Query String (URL) Filter Web Part and another Web Part to the Web Part Page.

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

Customize the Query String (URL) Filter Web Part:    


  1. In the Query String (URL) Filter Web Part, click the Open the tool pane link.

The Query String (URL) Filter Web Part enters Edit Mode, and the Web Part tool pane appears.

  1. 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. Enter a name in the Query String Parameter Name text box. This name must exactly match the name you define in the URL query string in step 11.
  3. Optionally, to enter an initial value in the Query String (URL) Web Part text box, enter a default value in the Default Value box. The value typically matches one of the values in the column that is specified in step 9. This default value is then used to display the initial list of values in the List View Web Part when the Web Part Page is first displayed.
  4. 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 a user that 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 parameter value by using the Web Part connection, select Send only the first value.
      • To pass two or more parameter 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.

The values must already be delimited by a character (For example: Preferred, Elite, Status), but you can use a different character.

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

Customize the other Web Part:    


  1. Click the Web Parts menu Web Part Edit Menu for the Web Part that you want to filter, and then point to Modify Shared Web Part.
  2. Customize the other Web Part the way you want. Find links to more information about customizing Web Parts in the See Also section.

Connect both Web Parts and verify the results:    


  1. Click the Web Part menu Web Part Edit Menu for the Query String (URL) Filter Web Part, point to Connections, point to Send Filter Values From, and then click the name of the other Web Part to which you want to link.
  2. Click Configure, select the field that you want to filter in the other Web Part from the list box, and then click Finish.
  3. To exit Edit Mode and view the page, at the top of the Web Part Page, under the Site Actions Button image menu, click Exit Edit Mode.
  4. On a Web page, create a link to the Web Part Page and add the query string parameter. For example:
  • If you are passing only one parameter, create the following link:
http://Fabercom/Sales/DeptData/Elites.aspx?Status=Elite
  • If you are passing two parameters, create the following link:
http://Fabercom/Sales/DeptData/Elites.aspx?Status=Elite&Status=Preferred

 Note   Do not use quotation marks (") with the name/value pair; they are interpreted as literal characters.

  1. To dynamically change the workbook results in the other connected Web Parts, display the Web Part Page by clicking the link that you defined in step 11.

Top of Page Top of Page

 
 
Applies to:
SharePoint Server 2007