其他分享
首页 > 其他分享> > rdlc中的调用钻取报告

rdlc中的调用钻取报告

作者:互联网

我有一个rdlc报告名称Attent.rdc,它使用三个参数employeeId,monthId和year来生成员工的每月出勤状态.

当我点击>>像按钮:

我需要调用钻取(在我的情况下为同一报告)报告中增加月份和年份的参数.

如何在rdlc报表中创建追溯甚至处理程序?

解决方法:

我的问题已经解决了.在rdlc中,有人调用了goto_report / goto_url ..它实际上是由追溯报表调用的.所以,如果我在回发URL之外创建一个甚至处理程序,例如

 protected void Page_Load(object sender, EventArgs e)
 { 

 if (!IsPostBack)
    {
       //otherscode u need
       //now call report first time
      string path = HttpContext.Current.Server.MapPath(your report path);
      ReportViewer1.Reset(); //important
      ReportViewer1.ProcessingMode = ProcessingMode.Local;
      ReportViewer1.LocalReport.EnableHyperlinks = true;

      LocalReport objReport = ReportViewer1.LocalReport;
      objReport.DataSources.Clear();
      objReport.ReportPath = path;

      // Add Parameter if you need
      List<ReportParameter> parameters = new List<ReportParameter>();
      parameters.Add(new ReportParameter("parameterName", ParameterValue));
      ReportViewer1.LocalReport.SetParameters(parameters);
      ReportViewer1.ShowParameterPrompts = false;
      ReportViewer1.ShowPromptAreaButton = false;
      ReportViewer1.LocalReport.Refresh();

      //Add Datasourdce
      ReportDataSource reportDataSource = new ReportDataSource();
      reportDataSource.Name = "odsReportData";
      reportDataSource.Value = YourReportDataSourseValue;
      objReport.DataSources.Add(reportDataSource);
      objReport.Refresh();
    }

    ReportViewer1.Drillthrough += new DrillthroughEventHandler(DemoDrillthroughEventHandler);

    }







   public void DemoDrillthroughEventHandler(object sender, DrillthroughEventArgs e)
   {
  /*Collect report parameter from drillthrough report*/
    ReportParameterInfoCollection DrillThroughValues = e.Report.GetParameters();
    Type parameterName = Type.Parse(DrillThroughValues[1].Values[0].ToString());

  /*Bind data source with report*/
    LocalReport localReport = (LocalReport)e.Report;
    localReport.DataSources.Clear();
    localReport.DataSources.Add(new ReportDataSource("odsData", reportData));
    localReport.EnableHyperlinks = true;     

   /*Add parameter to the report if report have paramerter*/
    List<ReportParameter> parameters = new List<ReportParameter>();
    parameters.Add(new ReportParameter("ParameterName", ParameterValue));
    localReport.SetParameters(parameters);
    localReport.Refresh();
}

标签:rdlc,c
来源: https://codeday.me/bug/20191201/2081188.html