gpt4 book ai didi

asp.net - 将参数传递给报表查看器

转载 作者:行者123 更新时间:2023-12-02 16:25:34 25 4
gpt4 key购买 nike

我想将参数传递到我的报告 View 。我有一个下拉列表,其中包含数据库中的值和一个用于在从下拉列表中选择项目后显示报告的按钮。

这是我编写的用于添加参数的代码

protected void Button1_Click(object sender, EventArgs e)
{
RenderReport();
}

protected void RenderReport()
{
try
{
ServerReport serverReport = ReportViewer1.ServerReport;
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
try
{
serverReport.ReportServerUrl = new Uri("http://hedinaily-pc/Reports_HEDI");
}
catch (Exception ex)
{
Logger.Error(ex.Message, "");
}
serverReport.ReportPath = "~/Diagrammes/PresenceTotale.rdlc";
ReportParameter employe = new ReportParameter();
employe.Name = "Employe";
employe.Values.Add(DropDownList1.SelectedValue);
ReportViewer1.ServerReport.SetParameters( new ReportParameter[] { employe });
ReportViewer1.Visible = true;
}

catch (Exception ex)
{
Logger.Error(ex.Message, "");

}

}

这是我的报告的数据集

enter image description here

当我检查日志文件时,我发现此错误:

The attempt to connect to the report server failed.  Check your connection information and that the report server is a compatible version.

谁能告诉我这个错误是从哪里来的。我花了几个小时在谷歌上搜索我发现了这个LINK但我无法解决它。

最佳答案

像这样尝试一下...

ReportViewer1.ServerReport.ReportPath = "FooReport.rdlc";
ReportParameter[] reportParameter = new ReportParameter[2];
reportParameter[0] = new ReportParameter("fooFromDate", dateFrom.ToShortDateString());
reportParameter[1] = new ReportParameter("fooDateTo", dateTo.ToShortDateString());
ReportViewer1.ServerReport.SetParameters(reportParameter);
ReportViewer1.ServerReport.Refresh();

此外,还必须调用 .Refresh() 方法,以便...显示报告..

关于asp.net - 将参数传递给报表查看器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12176865/

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