传递报告参数在VS 2010中RDLC报表来 [英] Passing Report Parameters to SubReport in VS 2010 RDLC

查看:339
本文介绍了传递报告参数在VS 2010中RDLC报表来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

传递报表参数在VS到报表2010 RDLC

Passing Report Parameters to SubReport in VS 2010 RDLC

我有一些麻烦界定和在设计视图中我可以右击并定义报表参数并使其穿过在VS 2008在2010年通过VS报表参数子报表。

I'm having some troubles defining and passing report parameters to subreports in VS 2010. In VS 2008 in the design view I was able to right click and define the report parameter and have it passed through.

在VS 2010中的提示丢失。所以我的问题是,如何从父报表的值传递给子报表在VS 2010中?

In VS 2010 that prompt is missing. So my question is, how can I pass a value from a parent report to a subreport in VS 2010?

此外,这就是显示在报告属性对话框VS 2010的内部:

Additionally, this is what is shown in the Report Properties dialog inside of VS 2010:

暂时我已经定义了报表参数在XML手动,但我收到来自主报告的错误,当我试图传递任何类型的报表的参数。

For the time being I have defined the parameter in the subreport manually in the XML but I'm receiving an error from the main report when I attempt to pass a parameter of any type to the subreport.

该错误是:

An error occurred during local report processing.

Value cannot be null. Parameter name: value

如果我没有在任何地方定义的参数值命名

Where I do not have a parameter named value defined anywhere.

推荐答案


  • 转到子报表 - > 报告数据窗格 - > 参数并添加要接收参数

  • Goto SubReport -> Report Data Pane -> Parameters and add the parameter you want to receive.

    转到 MainReport - > 右键单击子报表 - > 子报表属性 - > 参数并添加相同放慢参数名称并选择从下拉列表中相关数值。

    Goto MainReport -> Right-click SubReport -> Subreport Properties -> Parameters and add the same paramter name and pick the relevant value from the dropdown.

    在处理 SubreportProcessing 事件并设置报表数据源。在我的情况下,主报表数据源是键入列表与LT的;排序> 和参数为订单ID 。下面的示例code。

    Handle the SubreportProcessing event and set the datasource for the subreport. In my case the main report datasource was of type List<Order> and the parameter was OrderID. Sample code below.

    ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SetSubDataSource);
    

    public void SetSubDataSource(object sender, SubreportProcessingEventArgs e)
    {
        var mainSource = ((LocalReport) sender).DataSources["MainDataSet1"];
        var orderId = int.Parse(e.Parameters["OrderID"].Values.First());
        var subSource = ((List<Order>)mainSource.Value).Single(o => o.OrderID == orderId).Suppliers;
        e.DataSources.Add(new ReportDataSource("SubDataSet1", subSource));
    }
    

    这篇关于传递报告参数在VS 2010中RDLC报表来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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