Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I'm working on a crystal report that works fine.

I need to send 1 Discrete Value to the report. I use the following code and then add a parameter field with the Parameters name in it but when I run it it shows the viewer panel asking for a parameter input when I already specified its "25" and have dragged the field on the report where 25 should appear (please not its a hard-coded variable for demo purposes but will be code-side dynamic)

C#
ParameterField test;
         
test.ParameterFieldName = "TestID";
myDiscreteValue = new ParameterDiscreteValue();
int sTest = 25;
myDiscreteValue.Value = sTest;
test.CurrentValues.Add(myDiscreteValue);
 
reportParameters.Add(test);
Posted

1 solution

Hi, try the following code

<pre lang="c#">
CrystalDecisions.Shared.ParameterFields pfields =
new CrystalDecisions.Shared.ParameterFields();

CrystalDecisions.Shared.ParameterField pfieldTestID =
new CrystalDecisions.Shared.ParameterField();

CrystalDecisions.Shared.ParameterDiscreteValue disvalueTestID =
new CrystalDecisions.Shared.ParameterDiscreteValue();

disvalueTestID.Value = 25; // Parameter value
pfieldestID.Name = "TestID"; // Parameter Name

pfieldTestID.CurrentValues.Add(disvalueTestID);

pfields.Add(pfieldTestID);

crystalReportViewer1.ParameterFieldInfo = pfields;
</pre>

good luck,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900