Limit the Number of Records per Page

This tutorial demonstrates how to limit the number of records displayed on a report's pages.


This approach to limiting the number of data records displayed on report pages applies when the UserDesignerOptions.DataBindingMode is set to DataBindingMode.Bindings.

See Limit the Number of Records per Page to learn about the alternative approach to solving this task.

See Data Binding Modes to learn more about the available binding modes.

In this example, the number of data rows is passed to the report as a parameter.

HowTo - LimitNumberOfRecords_5

Do the following to limit the number of records displayed on a report's pages:

  1. To create a table report in this tutorial, start with a report that is bound to the "Products" table of the sample Northwind database (the nwind.mdb file included in the XtraReports installation). To learn more about binding a report to a data source, see Provide Data to Reports. In this tutorial, we will start with the following report layout.

    HowTo - LimitNumberOfRecords_0

  2. To add a parameter to the report, right-click the Parameters section in the Field List window, and choose Add Parameter in the invoked context menu.


  3. For the created parameter, define the Parameter.Description property, and set the Parameter.Type property to Number (integer).

    HowTo - LimitNumberOfRecords_1a

  4. Drop the XRPageBreak control from the DX.18.1: Report Controls Toolbox tab onto the report's Detail band, and place it at the top of the Detail table.

    HowTo - LimitNumberOfRecords_1

  5. For XRPageBreak, set the XRControl.Visible property to false, and click the ellipsis button for the XRControl.FormattingRules property.

    HowTo - LimitNumberOfRecords_2

    In the invoked Formatting Rules Editor, click the Edit Rule Sheet... button. The Formatting Rule Sheet Editor will appear.

    HowTo - LimitNumberOfRecords_2

  6. In this dialog, click Buttons_Plus, to create a new formatting rule. Then set its FormattingRuleCollection.Visible property to true, and click the ellipsis button for the FormattingRule.Condition property to invoke the Condition Editor.

    HowTo - LimitNumberOfRecords_3

  7. In the Condition Editor, define the following expression for the rule: ([DataSource.CurrentRowIndex] % [Parameters.parameter1] == 0) And ([DataSource.CurrentRowIndex] != 0).

    HowTo - LimitNumberOfRecords_4

    Click OK, to save the changes and close the dialog. Then click Close to quit the Formatting Rule Sheet Editor.

  8. Next, in the Formatting Rules Editor, you can see the newly created rule (called formattingRule1), which should be moved to the list of active rules on the right using the arrow buttons in the center of the dialog.

    How to - ConditionallyFilterData_3

    Click OK to close the editor.