I use VS2008, with built in Crystal Decisions. I am trying to pass parameters to an ASP.net application programatically.
When I run the application and step through it in development mode, I can see that all three parameters are passed to the reportviewer.ParameterFieldInfo property. However the application then asks for the third parameter using the user input parameter screen as if it did not get passed. If I enter a value for it, I then get another user input parameter screen asking for the first two parameters, and so on, back and forth without ever displaying the report.
Here is my code:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ReportDocument reportDocument = new ReportDocument();
ParameterFields paramFields = new ParameterFields();
ParameterField paramFieldAgency = new ParameterField();
ParameterDiscreteValue paramAgencyDiscreteValue = new ParameterDiscreteValue();
//Set instances for input parameter 1 - @agencyName
paramFieldAgency.Name =
"@agencyName";
//*Remember to reconstruct the parameterDiscreteValue
//and parameterField objects
paramAgencyDiscreteValue.Value = Session[
"agencyName"].ToString();
paramFieldAgency.CurrentValues.Add(paramAgencyDiscreteValue);
ParameterField paramFieldStartDate = new ParameterField();
ParameterDiscreteValue paramStartDateDiscreteValue = new ParameterDiscreteValue();
//Set instances for input parameter 2 - @startdate
paramFieldStartDate.Name =
"@startdate";
//*Remember to reconstruct the parameterDiscreteValue
//and parameterField objects
paramStartDateDiscreteValue.Value = Session[
"reportStartDate"].ToString();
paramFieldStartDate.CurrentValues.Add(paramStartDateDiscreteValue);
ParameterField paramFieldEndDate = new ParameterField();
ParameterDiscreteValue paramEndDateDiscreteValue = new ParameterDiscreteValue();
//Set instances for input parameter 3 - @endDate
paramFieldEndDate.Name =
"@endDate";
//*Remember to reconstruct the parameterDiscreteValue
//and parameterField objects
paramEndDateDiscreteValue.Value = Session[
"reportEndDate"].ToString();
paramFieldEndDate.CurrentValues.Add(paramEndDateDiscreteValue);
//Add the paramField to paramFields
paramFields.Add(paramFieldAgency);
paramFields.Add(paramFieldStartDate);
paramFields.Add(paramFieldEndDate);
AgencyUtsteinCrystalReportViewer.ParameterFieldInfo = paramFields;
reportDocument.Load(
"myAbsolutePath");
//Load the report by setting the report source
AgencyUtsteinCrystalReportViewer.ReportSource = reportDocument;
//set the database loggon information.
AgencyUtsteinCrystalReportViewer.Visible =
true;
reportDocument.SetDatabaseLogon(
"myUserName", "myPassword", "mySQLServer", "myDatabasee");
AgencyUtsteinCrystalReportViewer.DataBind();
}
}
Does anyone know why and how to fix this? Any help would be greatly appreciated.