添加参数后,SubReport不起作用 [英] SubReport is not working after adding parameter

查看:182
本文介绍了添加参数后,SubReport不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究VS2012上的RDLC报告

I am working on RDLC report On VS2012

当我尝试在子报表中添加参数时,我的报表无法正常工作,并且出现此错误错误:无法显示子报表."

When I am trying add a parameter on my Sub report then my report is not working and I am getting this error "Error: Sub report could not be shown."

在添加参数之后,甚至没有调用此事件LocalReport_SubreportProcessing(对象发送者,SubreportProcessingEventArgs e).

And after adding parameter this event LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e) is not even called.

推荐答案

我意识到我在这里参加聚会迟到了,但是在搜索过程中出现了这个问题,因此也许会对某人有所帮助.我终于在我的Web应用程序的主报告中找到了sup报告.

I realize that I'm late to the party here but this question came up during my searches so maybe this will help someone. I finally got sup reports working in my main report of my web application.

在我添加的Page_Load中

in Page_Load I added

ReportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(SetSubDataSource);
this.ReportViewer1.LocalReport.Refresh();

然后我添加了活动

public void SetSubDataSource(object sender, SubreportProcessingEventArgs e)
{
    var report = ((LocalReport)sender).DataSources[0];
    var tableid = e.Parameters["tableId"].Values[0];
    ObjectDataSource2.SelectParameters[0].DefaultValue = tableid;
    e.DataSources.Add(new ReportDataSource("DataSet2", ObjectDataSource2));
}

您还需要确保主报表的子报表具有正确定义的参数和数据以及子报表本身.这对我使用带有一个参数的存储过程有效,但是我认为一旦正确触发,就很容易添加其他参数.我还将子报表数据类型的常规选项设置为Integer(我的存储过程期望的类型),并允许为null,并将默认值设置为"Specify values",并将其保留为(Null).

You'll also need to make sure that your main report's sub report has the correctly defined parameter and data as well as the sub report itself. This works for me using a stored procedure with one parameter but I assume it's easy to add additional params once this is firing correctly. I also set the general options of my sub report data type to Integer (the type my sproc was expecting) and to allow nulls as well as set the default value as "Specify values" and left it as (Null).

当我添加

<SelectParameters>
    <asp:Parameter Name="tableId" Type="Int32" />
</SelectParameters>

在我的子报表的数据源对象的ObjectDataSource2节点内,您的行驶里程可能会有所不同.

inside the ObjectDataSource2 node of my sub reports data source object, your mileage may vary.

这篇关于添加参数后,SubReport不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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