RDLC 子报表运行模式
来源:互联网 发布:儿歌知错的小鸭 编辑:程序博客网 时间:2024/05/17 09:11
在开发RDLC子报表时,大致上的程式码会是如下
// 显示Report的Method private void Show_Report(){ .... .... // 指定子报表事件处理常式 this .ReportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(LocalReport_SubreportProcessing); // Run Query SQL存入datatable,然后指定给RDLC报表档(程式码略…..) …. …. this .ReportViewer1.LocalReport.DataSources.Add( new Microsoft.Reporting.WebForms.ReportDataSource( " XXXXX " , dt)); this .ReportViewer1.LocalReport.Refresh();}void LocalReport_SubreportProcessing( object sender, SubreportProcessingEventArgs e){ // Exec子报用的Query SQL存入datatable,然后指定给RDLC报表档(程式码略…..) ...... ...... e.DataSources.Add( new Microsoft.Reporting.WebForms.ReportDataSource( " XXXXX " , dt);}
然而值得注意的是,这样的方式在LocalReport_SubreportProcessing里是每一页主报表的资料都会进去Query一次子报用的Query SQL,所以当你把报表设计成不分页的情况下,会变成像是在一个Loop里不断的Query SQL,所以报表资料愈多,Query愈多次,效能肯定不会太好,因此较好的写法可以改成如下的方式,原理就是减少重覆执行Query的动作
private void Show_Report(){ // 一次Query主报表及子报表要用的资料,放入所属的DataTable // master_dt (程式码略...) // sub_dt (程式码略...) // 指定子报表事件处理常式 this .ReportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(LocalReport_SubreportProcessing); this .ReportViewer1.LocalReport.DataSources.Add( new Microsoft.Reporting.WebForms.ReportDataSource( " xxx " , master_dt)); this .ReportViewer1.LocalReport.Refresh();}void LocalReport_SubreportProcessing( object sender, SubreportProcessingEventArgs e){ // 利用Sub DataTable的资料,直接指定给子报用就好,不再重覆Query e.DataSources.Add( new Microsoft.Reporting.WebForms.ReportDataSource( " xxxxx " , sub_dt);}
- RDLC 子报表运行模式
- RDLC子报表
- RDLC子报表的备忘录
- RDLC子报表钻取
- C# RDLC子报表Subreport
- RDLC 报表系列(四) 子报表的使用
- .NET 自带报表 Rdlc 动态增加子报表
- RDLC 报表系列(四) 子报表的使用
- RDLC报表
- RDLC报表
- RDLC报表
- RDLC报表
- RDLC报表
- RDLC报表
- RDLC报表
- RDLC报表
- RDLC报表
- RDLC报表
- js中undefined,null,NaN的区别
- Android仿QQ空间
- C# WinForm:无法访问已释放的对象
- Python中正则表达式的用法
- :after 伪元素
- RDLC 子报表运行模式
- 购物车
- Django中对数据库的操作说明
- IE6、IE7、IE8、Firefox、Opera、谷歌浏览器、Safari CSS hack区分,浏览器兼容性
- 用session获取登陆页面消息代码
- C语言中除法怎么取得小数
- Vs2010连接Mysql数据库方法
- 设计模式笔记
- Activity启动分析