0perator 0perator - 5 months ago 17
C# Question

Use a single collection to hold all parameters

I take user input on a form and bind it to a parameter which will then tie to my report. Can I use a single collection to hold all of my parameters? It seems redundant to have to create a collection and a parameter for every item I want to pass to my report.

To make this work the way I require, I've had to add a collection for each param on my form:

// #1 Setup a collections
ParameterValues firstNameCollection = new ParameterValues();
ParameterValues lastNameCollectoin = new ParameterValues();

Then I created the actual parameter:

// #2 Set the parameters
ParameterDiscreteValue firstNameParam = new ParameterDiscreteValue();
ParameterDiscreteValue lastNameParam = new ParameterDiscreteValue();

Bound the value:

// #3 Set the values
firstNameParam.Value = "First Name";
lastNameParam.Value = "Last Name";

Added the parameters to the collection:

// #4 Add the parameters to the collection

And applied the collections to the form:

// #5 Apply the collections to the report


The proper way to fill a Crystal Report Parameter in C#.

MyReport.SetParameterValue("NameOfReportParam", Object);

In the initial question, I creating the parameter vs just referencing it as shown here.