This documentation is archived and is not being maintained.

Sorting Data in a ReportViewer Report 

The data within each of the data regions (table, matrix, and list) can be sorted by fields and expressions. You can configure a report to support end-user sorting, allowing users to interactively change the sort order while viewing a report. Alternatively, you can use parameters to sort data prior to displaying it in the report.

Setting Sort Properties on Data Regions

Data regions are data-bound report items that are used to display repeating rows of data. You can set sort properties on any data region to determine how and in what order the rows are sorted.

Interactive Sorting

You can set properties on column headings to provide interactive sorting in a published report. Sorting is specified through text box properties. You can specify sorting for multiple columns in the same table, list, or matrix; and for nested or grouped data.

To specify interactive sorting

  1. Right-click a column heading (for example, a column in a table header), and select Properties to open the Textbox Properties dialog box.

  2. Click the Interactive Sort tab.

  3. Select Add an interactive sort action to this text box.

  4. To specify a sort expression, select the field that corresponds to the column for which you are defining a sort action (for example, for a column heading named "Department", choose =Fields!Department.Value). Specifying a sort expression is required.

  5. Select the data region and scope for the sort. This step determines whether the sort action applies to all of the data regions in a report, is limited to the data region that contains the text box, or is scoped to some other set of data regions that you choose.

  6. Click OK.

To verify the sort action, you can preview the report. Columns that support interactive sorting have arrow icons to indicate sort order. To toggle the sort order between ascending and descending order, click the column heading.

Parameterized Sorting

You can use report parameters to change the sorting properties of a data region or group. For example, you could change the sort expression for the Product table on the report, so that it sorts by product name or price. At run time, the user selects the sort field to use.

  • Create a report parameter that will be used to accept a sort selection from the user.

  • In the Report Parameters dialog box, select the fields that can be used to sort on. The available values should correspond to fields in the dataset. If you are sorting on a grouping, you can specify a sort order on aggregated values. Sorting on aggregated values is not supported for datasets or data regions.

  • Add a drop-down list in the form or Web page so that a user can make a selection from the available values.

See Also