Question

I'm tying to use .split to pass multiple values to a multiple value enabled parameter. If I select 4 items, 4 values will be passed into the crystal report but all 4 will have the same value of the last item (i.e. if I select 1,2,3,4 the crystal report receives 4,4,4,4).

ParameterField f1 = CrystalReportViewer1.ParameterFieldInfo["Emp Id"];
ParameterDiscreteValue v1 = new ParameterDiscreteValue();
string LBL1 = Request.QueryString["LBL1"].ToString();
string[] LBL1split = LBL1.Split(',');

foreach (string item in LBL1split)
{
    v1.Value = item;
    f1.CurrentValues.Add(v1);
}

Is the new value overridding the existing items in .CurrentValues?

Thanks

Was it helpful?

Solution

You should notice that you are passing a class to the CurrentValues.Add method

so the only thing you have to change is this:

put ParameterDiscreteValue v1 = new ParameterDiscreteValue(); to the loop

ParameterField f1 = CrystalReportViewer1.ParameterFieldInfo["Emp Id"];
string LBL1 = Request.QueryString["LBL1"].ToString();
string[] LBL1split = LBL1.Split(',');

foreach (string item in LBL1split)
{
    ParameterDiscreteValue v1 = new ParameterDiscreteValue();
    v1.Value = item;
    f1.CurrentValues.Add(v1);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top