Hi,
When the Refresh button is clicked in the Crystal Report Viewer, the parameter input prompt appears but the previously entered parameter values are not retained. I have a requirement where the user wants to see the previously entered parameter values on the prompt when a report is refreshed and then if needed the user can change the parameter value.
I am using the crystal report viewer embedded in an ASP.NET Webform page (.ASPX). The reports are hosted on the server and are dynamically loaded. The parameter values are not being set programmatically but rather the user sets the parameter values when the report is loaded and the parameter prompt appears.
This is how the code looks like:
this.reportDoc = new ReportDocument();
reportDoc.Load(filename: Server.MapPath(p));
//Get SQL Server Details
string zServer = “SQL Server Name”;
string zDatabase = “Database Name”;
string zUsername = “UserName”;
string zPassword = “Password”;
var ciReportConnection = new ConnectionInfo
{
ServerName = zServer,
DatabaseName = zDatabase,
UserID = zUsername,
Password = zPassword
};
//Assign data source details to tables
TableLogOnInfo logOnInfo = new TableLogOnInfo();
try
{
foreach (CrystalDecisions.CrystalReports.Engine.Table table in reportDoc.Database.Tables)
{
logOnInfo = table.LogOnInfo;
logOnInfo.ReportName = reportDoc.Name;
logOnInfo.ConnectionInfo = ciReportConnection;
logOnInfo.TableName = table.Name;
table.ApplyLogOnInfo(logOnInfo);
table.Location = table.Name;
}
foreach (ReportDocument subreport in reportDoc.Subreports)
{
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in subreport.Database.Tables)
{
logOnInfo = CrTable.LogOnInfo;
logOnInfo.ConnectionInfo = ciReportConnection;
logOnInfo.TableName = CrTable.Name;
CrTable.ApplyLogOnInfo(logOnInfo);
CrTable.Location = CrTable.Name;
}
}
}
catch
{
throw;
}
//Assign data source details to the report viewer
if (this.CrystalReportViewer1.LogOnInfo != null)
{
TableLogOnInfos tlInfo = this.CrystalReportViewer1.LogOnInfo;
foreach (TableLogOnInfo tbloginfo in tlInfo)
{
tbloginfo.ConnectionInfo = ciReportConnection;
}
}
}
CrystalReportViewer1.ReportSource = reportDoc;
CrystalReportViewer1.RefreshReport();
Note:
I tried using the following
CrystalReportViewer1.EnableParameterPrompt = true;
The below line in bold font allows me to reuse the parameter values on Refresh but the parameter prompt itself is not being displayed. The report just refreshes by reusing the parameter values.
CrystalReportViewer1.ReuseParameterValuesOnRefresh = true;
Can someone please guide me if this is possible on Crystal Reports Viewer? I was told that the reports hosted on Crystal Enterprise Server are able to retain parameter values on the prompt when refreshed in the viewer.