Symptom
When working with the Crystal Reports .NET SDK the parameter
default value descriptions disappear when a new value is added to
the default value collection.
Cause
This is a known issue and has been tracked with ADAPT01001228.
Resolution
In order to resolve this issue you need to use the ParameterFieldDefinitions collection instead of the ParameterFields collection. When using the ParameterFieldDefinitions you also need to make sure you use the ApplyDefaultValues method to commit the changes.
For example:
ReportDocument boReportDocument;
ParameterFieldDefinition boParameterFieldDefinition;
ParameterDiscreteValue boParameterDiscreteValue;
ParameterValues boParameterDefaultValues;
// Load the report
boReportDocument = new ReportDocument();
boReportDocument.Load(Server.MapPath("parameter report.rpt"));
// Get the first parameter in the ParameterFieldDefinition collection
boParameterFieldDefinition = boReportDocument.DataDefinition.ParameterFields[0];
// Get the original default values
boParameterDefaultValues = boParameterFieldDefinition.DefaultValues;
// Create a new ParameterDiscreteValue to add to the original default values collection
boParameterDiscreteValue = new ParameterDiscreteValue();
boParameterDiscreteValue.Value = "This is a new value";
boParameterDiscreteValue.Description = "this is a new description";
// Add the new ParameterDiscreteValue to the original default values collection, then apply the values
boParameterDefaultValues.Add(boParameterDiscreteValue);
boParameterFieldDefinition.ApplyDefaultValues(boParameterDefaultValues);
// Set the ReportSource so the report can be previewed. Export or print code can be added here.
CrystalReportViewer1.ReportSource = boReportDocument;
Keywords
DEFAULTVALUES DOTNET NET .NET DEFAULT VALUES VALUE ADD CRYSTAL REPORTS PARAMETER PARAMETERFIELD PARAMETERFIELDDEFINITION FIELD DEFINITION , 5212238 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , Bug Filed
Product
Crystal Reports 2008 V0 ; SAP Crystal Reports 10.0 ; SAP Crystal Reports XI ; SAP Crystal Reports XI R2 ; SAP Crystal Reports, version for Visual Studio .NET 2005 ; SAP Crystal Reports, version for Visual Studio .NET 2008 ; SAP Crystal Reports, version for Visual Studio .NET 9.1