-
Notifications
You must be signed in to change notification settings - Fork 204
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.
- Open the report in the designer.
- From the menu choose Report → Report Parameters.
- Click Add to create a new parameter.
- 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
-
Name — identifier used in expressions and code (e.g.
Parameters are stored as <ReportParameter> elements in the RDL XML.
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 @EndDateThe engine binds the parameter values before executing the query.
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.
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.
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.
await ReportViewer.SetSourceFileAsync(new Uri(rdlPath));
ReportViewer.SetReportParametersAmpersandSeparated(
"StartDate=2024-01-01&EndDate=2024-12-31&CustomerId=42");
await ReportViewer.RebuildAsync();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();
}Beyond the ampersand string, RdlViewer accepts two other formats:
_rdlView.SetReportParameters(new Dictionary<string, string>
{
{ "StartDate", "2024-01-01" },
{ "EndDate", "2024-12-31" },
{ "CustomerId", "42" }
});
await _rdlView.Rebuild();_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.
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=42See Using RdlCmd for the full flag reference.
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.