如何将reportparameter添加到localreport,然后在rdlc报告(文本框)中引用它 [英] How do I add a reportparameter to a localreport and then reference it in a rdlc report(textbox)

查看:79
本文介绍了如何将reportparameter添加到localreport,然后在rdlc报告(文本框)中引用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using (LocalReport reportEngine = reportViewer1.LocalReport)                
                {       this.Instrument_ReadingsTableAdapter.Fill(this.LiveDataSetFromActualDB.Instrument_Readings);                 
                    reportEngine.ReportPath = Application.StartupPath + "\\Report1.rdlc";
                    //reportEngine.ReportPath = Application.StartupPath + "\\Report2.rdlc";
                    
                    // -- NEW CODE ADDED HERE
                    //ReportDataSource rds = new ReportDataSource();
                    //rds.Name = "Datasettest";
                    //rds

                    var dt_min = this.Instrument_ReadingsTableAdapter.Min();
                    var dt_max = this.Instrument_ReadingsTableAdapter.Max();

                    if (!dt_min.HasValue || !dt_max.HasValue)
                    {
                        return;
                    }

                    var diff = (dt_max.Value - dt_min.Value).TotalMinutes;

                    this.reportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc";

                    ReportParameter rp = new ReportParameter("Time_Span", diff.ToString());
                    reportEngine.SetParameters(new ReportParameter[] { rp });
                    this.reportViewer1.RefreshReport();





< b>我尝试了什么:



我收到错误

Microsoft.reporting.WinForms.LocalReport.InternalGetReportParameters( CatalogItemContextBase reportContext,NameValueCollection userSpecifiedValues,ParameterInfoCollection baseLineParameters,DatasourceCredentialsCollection credentials,ReportRuntimeSetup reportRuntimeSetup at Microsoft.Reporting.Winforms.LocalReport.SetParameters(IEnumerable1 parameters)

at

Live_AM_Report.Form1.Form1_Load (对象发送者,EventArgs e)

...第255行,其中= reportEngine.SetParameters(new ReportParameter [] {rp});



在rdlc的设计方面



我在报告数据中添加了一个名为Timespan的参数

我还添加了引用参数的文本框,现在是设置该pa值的简单情况rameter,文本框应该调用它。

文本框的值字段= [@Time_Span](我添加的参数)



我有现在已经挣扎了好几天,而且非常令人沮丧,任何帮助都会非常感激。



What I have tried:

I recieve an error
"Microsoft.reporting.WinForms.LocalReport.InternalGetReportParameters(CatalogItemContextBase reportContext, NameValueCollection userSpecifiedValues, ParameterInfoCollection baseLineParameters, DatasourceCredentialsCollection credentials, ReportRuntimeSetup reportRuntimeSetup at Microsoft.Reporting.Winforms.LocalReport.SetParameters(IEnumerable1 parameters)
at
Live_AM_Report.Form1.Form1_Load(Object sender, EventArgs e)
... line 255 , which = reportEngine.SetParameters(new ReportParameter[] { rp });

On the design side of the rdlc

I have added a parameter called Timespan in the "Report data"
I also added the textbox that refers to the parameter, now its a simple case of setting the value in that parameter, and the textbox should call it.
The Textbox's Value field = [@Time_Span] (The parameter i added)

I have struggled with this for a few days now, and its really frustrating, any help would be greatly appreciated.

推荐答案

将参数添加到RDLC报告中。

1.在Visual Studio中打开报告。

2.按CRL + ALT + D

3.报告数据选项卡打开。

4.选择参数并右键单击以添加参数。



在Set参数中

To Add Parameter to RDLC report.
1. Open report in Visual Studio.
2. Press CRL + ALT + D
3. "Report Data" tab gets open.
4. Select "Parameter" and right click to add parameter.

In Set parameter
ReportParameter[] rptParams = new ReportParameter[]
            {
                new ReportParameter("param1",txtParam1.Text),
                new ReportParameter("param2",txtParam2.Text)
};
rptInvoiceTC.LocalReport.SetParameters(rptParams);


这篇关于如何将reportparameter添加到localreport,然后在rdlc报告(文本框)中引用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆