crystal-reportsC#(cSharp) Crystal Reports 

How to pass multiple values to single SetParameterValue() in C# Crystal Reports

Passing multiple values to single SetParameterValue() in C# Crystal Reports

We faced this problem in Crystal Reports while filtering data based on multiple values for single parameter in c#
example: if you are using listitems and you are selecting multiple values to be passed to crystal report for filtering then you can use like this as below code snippet.

First add using system collections

using System.Collections;

then create one arraylist object and read listitem and add to arrayList as below (this below code is for listitems)

ArrayList arrayList = new ArrayList();
        foreach (ListItem item in CheckBoxList.Items)
        {
 
            if (item.Selected)
            {
                arrayList.Add(item.Value.ToString());
            }
        }

and (This below is code is for GroupSelectionList items)

ArrayList arrayList = new ArrayList();
for (int i = 0; i < groupSelectionList.Items.Count; i++){
	if (groupSelectionList.GetItemCheckState(i) == CheckState.Checked)
	{
		arrayList.Add(((ListItem)groupSelectionList.Items[i]).Value.ToString());
	}
}

Then at last add arraylist to SetParameterValue by typcasting it to array (ToArray())

 cryRpt.SetParameterValue("Pname", arrayList.ToArray());

 

 

Arjun is is a web developer/designer, who is fond of the web. He lives in Manipal, Karnataka, India.

Also Read:  Integrate Sendinblue Transactional Email in C#

Related posts