后台动态调用报表

关于Asp.net自带的报表有很多应用的方法,下面只是我在做项目过程中,所应用到的一部内容,仅以此记录一下。
若是有想深入学习的朋友,还请看Msdn。
前台设计
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace
="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<rsweb:ReportViewer ID="rvResultStatistics" runat="server" Font-Names="Verdana" 
        Font
-Size="8pt" InteractiveDeviceInfos="(集合)" WaitMessageFont-Names="Verdana" 
        WaitMessageFont
-Size="14pt" PageCountMode="Actual" Width="893px" 
        Height
="504px" ShowBackButton="False">
</rsweb:ReportViewer>

前台设计如图所示

后台代码如下:

 

                string dt = "%" + ddlYear.SelectedValue.ToString() + "%";
                domain 
= Helper.CheckLog().SelectCheckLog(dt);
                
if (ddlReportSort.SelectedItem.Text == "饼状图")
                {
                    
//设置数据源
                    ReportDataSource rds = new ReportDataSource("DataSet1", domain);
                    
this.rvResultStatistics.LocalReport.DataSources.Clear();
                    
this.rvResultStatistics.LocalReport.DataSources.Add(rds);
                }
                
else
                {
                    ReportDataSource rds 
= new ReportDataSource("RptByDateHistogramDataSet", domain);
                    
this.rvResultStatistics.LocalReport.DataSources.Clear();
                    
this.rvResultStatistics.LocalReport.DataSources.Add(rds);
                }

                
//指定报表文件路径
                this.rvResultStatistics.LocalReport.ReportPath = "../Reports/" + ddlReportSort.SelectedValue.ToString();
                
this.rvResultStatistics.DataBind();


 

posted @ 2011-08-30 15:56  佳园  阅读(493)  评论(0编辑  收藏  举报