SAP Knowledge Base Article - Public

2996161 - Setting Parameter in CR for VS WEB app does not work on first preview - SP 25 -> SP 29


 Setting parameter values in code does not use the value when first previewed


Crystal Report for Visual Studio SP 25 to SP 29

Reproducing the Issue

Simple WEB app using a report with a parameter:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;

public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

protected void Page_Init(object sender, EventArgs e)
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new ReportDocument();
rpt.Load(@"c:\My Parameter.rpt"); 
//CrystalReportViewer1.ReportSource = rpt;

Session.Add("rpt", rpt);

// this sets the report to the session
if (!IsPostBack)
CrystalReportViewer1.ReportSource = rpt;
CrystalReportViewer1.ReportSource = Session["rpt"];

CrystalDecisions.Shared.ParameterValues vParmValues = new ParameterValues();
CrystalDecisions.Shared.ParameterDiscreteValue vParmDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue();
CrystalDecisions.Shared.ParameterRangeValue vParmRangeValue = new CrystalDecisions.Shared.ParameterRangeValue();
CrystalDecisions.Shared.ParameterField vParmField = new CrystalDecisions.Shared.ParameterField();
String ParamValue1;

vParmValues = new CrystalDecisions.Shared.ParameterValues();
vParmDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue();

//hard code for easier testing
ParamValue1 = "works";

vParmDiscreteValue.Value = ParamValue1;
vParmField = (CrystalDecisions.Shared.ParameterField)CrystalReportViewer1.ParameterFieldInfo["My Parameter"];

vParmField.CurrentValues = vParmValues;



Is has been reported to R&D

Expecting the fix to be in SP 30 due out early February 2021


cr for vs, parameter, web, prompts for value , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem


SAP Crystal Reports, developer version for Microsoft Visual Studio