XtraReport通过代码传递参数

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}_
 
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值