报表控件 ActiveReports 中页面报表动态绑定数据源实现方法续:子报表篇

在<a href="http://blog.gcpowertools.com.cn/post/2013/05/17/ActiveReports-PageReport-RunTime-DataSource.aspx">报表控件 ActiveReports 中页面报表动态绑定数据源实现方法</a>博客中,我们介绍了可通过LocateDataSource来对【Dataset Provider】进行动态数据源绑定。在读者反馈中,有人询问,如果我有子报表,请问该如何动态绑定数据源呢?<a href="http://www.grapecity.com.cn/image.ashx?picture=AR_Page_LoadDataSource.gif"><img title="AR_Page_LoadDataSource" style="display: inline" alt="AR_Page_LoadDataSource" src="http://www.grapecity.com.cn/image.ashx?picture=AR_Page_LoadDataSource.gif" width="605" height="270" /></a>

发布于 2014/04/14 00:00

ActiveReports

报表控件 ActiveReports 中页面报表动态绑定数据源实现方法博客中,我们介绍了可通过LocateDataSource来对【Dataset Provider】进行动态数据源绑定。在读者反馈中,有人询问,如果我有子报表,请问该如何动态绑定数据源呢?

答案是肯定的,我们可以在已有demo基础上,扩展出子报表动态绑定数据源的办法。且原理相同,只不过没有通过PageDocument的LocateDataSource,而是通过WebViewer1.LocateDataSource 事件来绑定数据源。

AR_Page_LoadDataSource

 GrapeCity.ActiveReports.PageReport report1 = new GrapeCity.ActiveReports.PageReport(
new System.IO.
FileInfo(Server.MapPath("PageReport1.rdlx")));
            WebViewer1.LocateDataSource += WebViewer1_LocateDataSource;
            WebViewer1.Report = report1;


void WebViewer1_LocateDataSource(object sender, GrapeCity.ActiveReports.
LocateDataSourceEventArgs args)
        {
            if (args.DataSourceName == "DataSource2")
            {
                if (args.DataSetName == "DataSet2")
                {
                    args.Data = GetData2();
                }
            }
            if (args.DataSourceName == "DataSource1")
            {
                if (args.DataSetName == "DataSet1")
                {
                    args.Data = GetData();
                }
            }
        }

demo下载:

ActiveReports 报表控件| 下载试用

ActiveReports 是一款专注于 .NET 平台的报表控件,全面满足 HTML5 / WinForm / ASP.NET / ASP.NET MVC / WPF 等平台下报表设计和开发工作需求,作为专业的报表工具为全球超过 300,000 开发人员提供了全面的报表开发服务。

您对ActiveReports产品的任何技术问题,都有技术支持工程师提供1对1专业解答,点击此处即可发帖提问>>技术支持论坛

相关产品
推荐相关案例
关注微信
葡萄城社区二维码

关注“葡萄城社区”

加微信获取技术资讯

加微信获取技术资讯

想了解更多信息,请联系我们, 随时掌握技术资源和产品动态