若是有想深入学习的朋友,还请看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>
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();
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();