【问题标题】:how to get the parameter value using QueryString in CrystalReportViewer_init function in ASP.Net?如何在ASP.Net 的CrystalReportViewer_init 函数中使用QueryString 获取参数值?
【发布时间】:2018-05-22 10:55:47
【问题描述】:

我正在尝试将参数从一页传递到另一页。我在另一页上使用CrystalReportViewer

CrystalReportViewer1_Init(object sender, EventArgs e)函数,在那里我应该收到上一页的filename

这是我的代码

protected void CrystalReportViewer1_Init(object sender, EventArgs e)
{
    ReportDocument _rdStudents = new ReportDocument();

    string reportPath = Server.MapPath("~/CrystalReportFiles/Inventory/" + Request.QueryString[" filename "].ToString());
    //string reportPath = Server.MapPath("~/CrystalReportFiles/Inventory/WeightBarcorde.rpt");    This code is working
    _rdStudents.Load(reportPath);     
    CrystalReportViewer1.ReportSource = _rdStudents;
}

这是我的参数http://localhost:55047/CrytalReportTest.aspx?filename=WeightBarcorde.rpt

<a target="_blank" href="CrytalReportTest.aspx?filename=WeightBarcorde.rpt">WeightBarcorde.rpt</a>

我们可以在init函数中传递参数吗?或者我的代码有什么问题

【问题讨论】:

    标签: c# parameters query-string crystal-reports-viewer


    【解决方案1】:

    从查询字符串中删除空格。

    变化:

    Request.QueryString[" filename "]

    到:

    Request.QueryString["filename"]

    写入 VS 输出控制台,看看它是否真的在读取参数:

    System.Diagnostics.Debug.WriteLine(reportPath);

    这个答案也有帮助:

    https://stackoverflow.com/a/2827025/1821637

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多