Skip to content

Report Parameters

Peter Gill edited this page Jun 8, 2026 · 3 revisions

Report Parameters

Parameters let you pass values into a report at run time — filtering SQL queries, controlling layout, or displaying user-selected dates and IDs. This page covers defining parameters in the designer and supplying values from code.

Defining parameters in the designer

  1. Open the report in the designer.
  2. From the menu choose Report → Report Parameters.
  3. Click Add to create a new parameter.
  4. Set:
    • Name — identifier used in expressions and code (e.g. StartDate)
    • Data Type — String, Integer, DateTime, Boolean, Float
    • Prompt — label shown to the user in the viewer's parameter panel (leave blank to hide)
    • Default value — optional; used when no value is supplied

Parameters are stored as <ReportParameter> elements in the RDL XML.

Using parameters in SQL

Reference a parameter in a dataset query with the @Name placeholder (standard SQL parameterisation):

SELECT OrderId, CustomerId, Amount, OrderDate
FROM Orders
WHERE CustomerId = @CustomerId
  AND OrderDate BETWEEN @StartDate AND @EndDate

The engine binds the parameter values before executing the query.

Using parameters in expressions

Inside report item expressions use the shorthand or the full syntax:

{?StartDate}                         -- shorthand
=Parameters!StartDate.Value          -- full VB.NET syntax
="Orders for customer " & {?CustomerName}

See Expressions and Formulas for the full expression reference.

Passing parameters from code — no GUI export

Pass a Dictionary<string, string> to RunGetData. Keys must match the parameter names defined in the report exactly (case-sensitive).

using Majorsilence.Reporting.Rdl;

RdlEngineConfig.RdlEngineConfigInit();

var rdlp = new RDLParser(await File.ReadAllTextAsync("orders.rdl"))
{
    Folder = @"C:\reports"
};
using var report = await rdlp.Parse();

var parameters = new Dictionary<string, string>
{
    { "StartDate",  "2024-01-01" },
    { "EndDate",    "2024-12-31" },
    { "CustomerId", "42" }
};

await report.RunGetData(parameters);

var ofs = new OneFileStreamGen("orders.pdf", true);
await report.RunRender(ofs, OutputPresentationType.PDF);

Dates and numbers are supplied as strings; the engine converts them to the type declared in the report.

Passing parameters in the WinForms viewer

Append parameters to the Parameters property before calling Rebuild. The format is an ampersand-separated name=value string — include a leading &.

private async void Form1_Load(object sender, EventArgs e)
{
    RdlEngineConfig.RdlEngineConfigInit();
    await rdlView.SetSourceFile(new Uri(@"C:\reports\orders.rdl"));
    rdlView.Parameters += "&StartDate=2024-01-01&EndDate=2024-12-31&CustomerId=42";
    await rdlView.Rebuild();
}

If the report has parameters with a non-blank Prompt, the viewer shows a built-in parameter input panel above the report. Users can change values and click Run to re-render without any extra code.

Passing parameters in the Avalonia viewer

await ReportViewer.SetSourceFileAsync(new Uri(rdlPath));
ReportViewer.SetReportParametersAmpersandSeparated(
    "StartDate=2024-01-01&EndDate=2024-12-31&CustomerId=42");
await ReportViewer.RebuildAsync();

Passing parameters in the WPF viewer

private async void Window_Loaded(object sender, RoutedEventArgs e)
{
    RdlEngineConfig.RdlEngineConfigInit();
    await rdlWpfViewer.SetSourceFile(new Uri(@"C:\reports\orders.rdl"));
    rdlWpfViewer.Parameters += "&StartDate=2024-01-01&CustomerId=42";
    await rdlWpfViewer.Rebuild();
}

Alternative parameter formats for viewers

Beyond the ampersand string, RdlViewer accepts two other formats:

IDictionary

_rdlView.SetReportParameters(new Dictionary<string, string>
{
    { "StartDate",  "2024-01-01" },
    { "EndDate",    "2024-12-31" },
    { "CustomerId", "42" }
});
await _rdlView.Rebuild();

JSON

_rdlView.SetReportParametersAsJson(
    """{"StartDate":"2024-01-01","EndDate":"2024-12-31","CustomerId":"42"}""");
await _rdlView.Rebuild();

All three formats (Parameters +=, SetReportParameters, SetReportParametersAsJson) are interchangeable — use whichever fits your calling code best.

Passing parameters via RdlCmd

Use the -p:Name=Value flag, repeating it for each parameter:

RdlCmd -f "orders.rdl" -o "orders.pdf" -t pdf \
       -p:StartDate=2024-01-01 \
       -p:EndDate=2024-12-31 \
       -p:CustomerId=42

See Using RdlCmd for the full flag reference.

Multi-value parameters

For a parameter that accepts multiple values (e.g. a list of statuses), declare the parameter as multi-value in the designer and pass a comma-separated string:

{ "StatusFilter", "Active,Pending,Review" }

The SQL WHERE clause should use IN with the parameter, and the dataset must be configured to split on the delimiter. Refer to your data provider's multi-value syntax.

Clone this wiki locally