Telerik 在 Silverlight 中报告,参数未到达服务器
本文关键字:服务器 参数 Silverlight 报告 Telerik | 更新日期: 2023-09-27 17:57:18
我是这样传递参数的:
public PrintReport()
{
InitializeComponent();
this.ReportViewer1.RenderBegin += new Telerik.ReportViewer.Silverlight.RenderBeginEventHandler(ReportViewer1_RenderBegin);
}
void ReportViewer1_RenderBegin(object sender, Telerik.ReportViewer.Silverlight.RenderBeginEventArgs args)
{
args.ParameterValues["ObjectTypeId"] = 40;
args.ParameterValues["Page"] = 1;
args.ParameterValues["PageSize"] = 10;
}
在服务器中,我正在这样做:
public partial class ObjectInstancesReport : Telerik.Reporting.Report
{
private IEnumerable<ObjectInstance> _objectInstances;
public ObjectInstancesReport()
{
InitializeComponent();
var objectTypeId = this.ReportParameters["ObjectTypeId"].Value == null ? 40 : (int)this.ReportParameters["ObjectTypeId"].Value;
var searchText = (string)this.ReportParameters["SearchText"].Value;
var page = this.ReportParameters["Page"].Value == null ? 1 : (int)this.ReportParameters["Page"].Value;
var pageSize = this.ReportParameters["PageSize"].Value == null ? 20 : (int)this.ReportParameters["PageSize"].Value;
但我只得到空值
找到答案,参数在构造函数上不可用,需要使用这个:
public ObjectInstancesReport()
{
//
// Required for telerik Reporting designer support
//
InitializeComponent();
table1.ItemDataBinding += new EventHandler(table1_ItemDataBinding);
this.DataSource = null;
this.Report.NeedDataSource += new EventHandler(Report_NeedDataSource);
}
void Report_NeedDataSource(object sender, EventArgs e)
{
var objectTypeId = this.ReportParameters["ObjectTypeId"].Value == null ? 1 : Convert.ToInt32(this.ReportParameters["ObjectTypeId"].Value);
var searchText = (string)this.ReportParameters["SearchText"].Value;
var page = this.ReportParameters["Page"].Value == null ? 1 : Convert.ToInt32(this.ReportParameters["Page"].Value);
var pageSize = this.ReportParameters["PageSize"].Value == null ? 20 : Convert.ToInt32(this.ReportParameters["PageSize"].Value);