Back to Devexpress

ParameterBinding Class

xtrareports-devexpress-dot-xtrareports-dot-ui-47ed8589.md

latest3.2 KB
Original Source

ParameterBinding Class

Enables you to pass the value of a report parameter to a subreport placed in a another report.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public class ParameterBinding :
    ParameterBindingBase
vb
Public Class ParameterBinding
    Inherits ParameterBindingBase

Example

This example illustrates how to pass the value of a report parameter to a subreport placed in a another report.

To do this, create a ParameterBinding object and add it to the XRSubreport.ParameterBindings collection.

In this example, the main report is bound to the Categories table of thesample Northwind database. A detail report should use data from the Products table of the same database and contain an appropriate CatID parameter.

To learn how to solve this task without writing any code, see Creating a Master-Detail Report using Subreports.

csharp
using DevExpress.XtraReports.UI;
// ...

private void XtraReport1_BeforePrint(object sender, System.ComponentModel.EventArgs e) {
    XtraReport report = sender as XtraReport;
    XRSubreport subreport = report.FindControl("xrsubreport1", true) as XRSubreport;
    ParameterBinding parameterBinding = new ParameterBinding("CatID", null, "Categories.CategoryID");
    subreport.ParameterBindings.Add(parameterBinding);
}
vb
Imports DevExpress.XtraReports.UI
' ...

Private Sub XtraReport1_BeforePrint(sender As Object, e As System.ComponentModel.EventArgs)
    Dim report As XtraReport = TryCast(sender, XtraReport)
    Dim subreport As XRSubreport = TryCast(report.FindControl("xrsubreport1", True), XRSubreport)
    Dim parameterBinding As New ParameterBinding("CatID", Nothing, "Categories.CategoryID")
    subreport.ParameterBindings.Add(parameterBinding)
End Sub

Inheritance

Object ParameterBindingBase ParameterBinding

See Also

ParameterBinding Members

ParameterBindingCollection

ParameterBindings

DevExpress.XtraReports.UI Namespace