Skip to Content
author's profile photo
Former Member

Passing Parameter from ASPX to CR Viewer 2010

All,

I am building a web application that uses Crystal Reports for products like invoices. I developed a report called CharterDetail.rpt that has a parameter {?TourID}.

From my web application we call the URL

http://www.someweblink.com/cats/reports/view.aspx?rfn=CharterDetail.rpt&tourid=1008

which calls this View.aspx.cs page code.

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using CrystalDecisions.Shared;

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Web;

public partial class _Default : System.Web.UI.Page

{

private String reportPath = "C:
cats
reports
";

protected void Page_Load(object sender, EventArgs e)

{

String reportFile = Request.QueryString["rfn"];

String tourId = Request.QueryString["tourid"];

if (reportFile != "" && reportFile != null)

{

ReportDocument rd = new ReportDocument();

ParameterField pf = new ParameterField();

ParameterFields pfs = new ParameterFields();

ParameterDiscreteValue pdv = new ParameterDiscreteValue();

pf.Name = "@TourID";

pdv.Value = tourId;

pf.CurrentValues.Add(pdv);

pfs.Add(pf);

CrystalReportViewer1.ParameterFieldInfo = pfs;

rd.Load(reportPath + reportFile);

CrystalReportViewer1.ReportSource = rd;

}

}

}

If I don't pass the {?TourID} parameter in the URL I am able to load the report and it prompts me for the input parameter. I enter the parameter and it displays properly.

If I include the parameter in the URL then I get an error in that says "The parmeter is incorrect"

I'm missing something fundamental. I believe I haven't got the report configured properly but have not been able to find a property that will make a difference . Any help is appreciated.

bob4fit

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    Posted on May 04, 2011 at 01:31 PM

    Make sure you're on [SP1|http://www.sdn.sap.com/irj/boc/support?rid=/webcontent/uuid/d01fdad8-44e5-2d10-61ad-9d2d4158f3a8] [original link is broken];

    Have a look at some parameter samples [here|https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples]. Start with csharp_win_paramengine.zip, csharp_win_paramviewer.zip, csharp_win_rangeparameters.zip.

    Also, there are a number of KBases you should be able to find using the search box in the top right corner of this web page. And don't forget to search the forums.

    - Ludek

    Add comment
    10|10000 characters needed characters exceeded