I am doing a crystal report, and I would like to dinamiclly add parameters.
I did the code which adds the value to one parameter, which I have created in the crystalReportViewer:
CrystalReport1 cr = new CrystalReport1();
cr.SetParameterValue("ParameterName", ParameterValue);
crystalReportViewer1.ReportSource = cr;
crystalReportViewer1.Refresh();
But this is for only one value.
Now I would like to put more values for that ParameterName. This is the code I fould on this forum, but the problem is that I do not know what to pass for "ParameterFields paramFields":
This is where I get the ParameterNames:
foreach (string myParamName in allParamNames)
{
AddParameter("myParameterField", myParameterName, /*WHAT COMES HERE? - to pass the 3rd value to the method bellow*/ );
}
private ParameterFields AddParameter
(string paramName, string paramValue,
ParameterFields paramFields) //I do not know what to pass to here!
{
ParameterField paramField= new ParameterField ();
ParameterDiscreteValue paramDiscreteValue = new
ParameterDiscreteValue ();
ParameterValues paramValues = new ParameterValues ();
// Set the name of the parameter <strong class="highlight">to</strong> modify.
paramField.ParameterFieldName = paramName;
// Set a value <strong class="highlight">to</strong> the parameter.
paramDiscreteValue.Value = paramValue;
paramValues.Add (paramDiscreteValue);
paramField.CurrentValues = paramValues;
// Add the parameter <strong class="highlight">to</strong> the ParameterFields collection.
paramFields.Add (paramField);
return paramFields;
}