Sort data in a Data view

When you sort data in a Data View, you modify the order in which the data appears. By sorting data, you present the information in an order that works best for you, instead of the order in which the data was originally entered. You can also sort on multiple fields by adding more fields to the sort order list. You can also add a toolbar to the Data View so that site visitors can sort or group data through the browser.

There may be times when you need to create a sort order that uses more complex criteria than you can specify in the Sort dialog box. In such a case, you can sort on an XPath expression that you create by using the options in the Advanced Sort dialog box.

To sort data in a Data View

  1. In Design view, click the Data View to select it.

  2. On the Data View menu, click Sort.

  3. In the Sort dialog box, under Available fields, click the field that you want to sort on, and then click Add.

  4. If no fields appear under Available fields, double-click More Fields, click the field that you want to sort on, and then click OK.

  5. Under Sort Properties, do one of the following:

    • To sort a field from lowest to highest (for example, A, B, C, or 1, 2, 3), click Ascending.

    • To sort a field from highest to lowest (for example, Z, Y, X, or 3, 2, 1), click Descending.

      Tip

      To change the sort order of a field from ascending to descending, or the reverse, double-click the field in the Sort order list. The triangle next to the field name indicates whether a field is sorted in ascending or descending order.

  6. Optional: To sort on multiple fields, add more fields to the Sort order list.

  7. Optional: To change the order in which the fields are sorted, click a field in the Sort order list, and then click Move Up or Move Down.

To create an advanced sort order

  1. In Design view, click the Data View to select it.

  2. On the Data View menu, click Sort.

  3. In the Sort dialog box, under Sort Properties, click Edit Sort Expression.

    Tip

    You can also open the Advanced Sort dialog box by double-clicking Add Sort Expression under Available Fields in the Sort and Group dialog box.

  4. In the Advanced Sort dialog box, under Select a field to insert, double-click the field that you want to insert in the expression. To insert the full path of the field, hold down CTRL while you double-click the field.

  5. In the Edit the XPath expression box, position the insertion point immediately after the field name, and then press SPACEBAR. The IntelliSense list of XPath operators appears.

  6. In the IntelliSense list of operators, double-click the operator that you want. The IntelliSense list of available fields appears.

  7. In the list of available fields, double-click the field that you want. At the bottom of the dialog box, you can see a preview of the results of the filter as you build the expression in the Edit the XPath expression box.

To remove a sort order

  1. In Design view, right-click the Data View, and then click Show Common Control Tasks.

  2. In the Common Data View Tasks list, click Sort and Group.

  3. In the Sort and Group dialog box, under Sort order, click the field that you want to remove from the sort order, and then click Remove.

See also

Concepts

Data views

Add a Data view

Apply conditional formatting to a Data view

Create a formula column in a Data view

Change the layout of a Data view

Modify the columns in a Data view

Filter data in a Data view

Add RSS feeds to a page

Display sample data in a Data view