Pass Parameter Values in Code
The following code illustrates how to assign a value to a report parameter:
using System;
using System.Windows.Forms;
// ...
// Create a report instance.
XtraReport1 report = new XtraReport1();
// Obtain a parameter and set its value.
report.Parameters["parameter1"].Value = 30;
// Hide the Parameters' UI from end-users (if you did not hide it at design time).
report.Parameters["parameter1"].Visible = false;
Also, you can update a parameter's value in a report's BeforePrint event handler or in a method that generates a report document (such as PrintTool.ShowPreviewDialog or PrintTool.ShowRibbonPreviewDialog).
#Pass Parameter Values to a Web Report in a URL
Add the Web Document Viewer to your web page and handle the Page_Load event. In the event handler, create a new report instance, find the parameter in the report's Parameters collection and obtain the parameter value from the Request.QueryString property.
using DevExpress.XtraReports.Web;
//...
protected void Page_Load(object sender, EventArgs e) {
XtraReport1 report = new XtraReport1();
report.Parameters["parameter1"].Value = Convert.ToInt32(Request.QueryString["parameter1"]);
ASPxWebDocumentViewer1.OpenReport(new CachedReportSourceWeb(report));
}
Run the application and pass the parameter value to your web page as shown below:
Viewer.aspx?parameter1=100
You can also pass values for multiple parameters. Separate parameter values with the & character:
_{WebPageURL}?{ParameterName1}={ParameterValue1}&{ParameterName2}={ParameterValue2}_