gpt4 book ai didi

c# - 在 rdlc 中调用钻取报告

转载 作者:行者123 更新时间:2023-11-30 16:25:17 24 4
gpt4 key购买 nike

我有一个名为 attendence.rdlc 的 rdlc 报告,它采用三个参数 employeeId、monthId 和 year 来生成员工的每月出勤状态。喜欢 enter image description here

当我点击 >> 按钮时: enter image description here

我需要调用钻取(在我的例子中是同一报告)报告增加月份和年份的参数。

enter image description here

如何在 rdlc 报告中创建钻取事件处理程序?

最佳答案

我的问题已经解决了。在 rdlc 中,当有人调用 goto_report/goto_url 时......它实际上是由 Drillthrough 报告调用的。所以如果我在回发 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();
}

关于c# - 在 rdlc 中调用钻取报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10106376/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com