The example in this article describes the method by which asp.net Crystal Report parameter fields are assigned in code. Share to everyone for your reference. The implementation method is as follows:
Declares the variables that are required to pass parameters to the viewer control.
Parameterfields paramfields = new Parameterfields ();
Parameterfield Paramfield = new Parameterfield ();
Parameterdiscretevalue discreteval = new Parameterdiscretevalue ();
Parameterrangevalue rangeval = new Parameterrangevalue (); The first parameter is a discrete parameter with multiple values.
Sets the name of the parameter field, which must match the parameters in the report.
Paramfield.parameterfieldname = "Customer Name";
Sets the first discrete value and passes it to the parameter.
Discreteval.value = "AIC childrens";
PARAMFIELD.CURRENTVALUES.ADD (Discreteval); Sets the second discrete value and passes it to the parameter.
The Discreteval variable is set to the new value so that the previous settings are not overwritten.
Discreteval = new Parameterdiscretevalue ();
Discreteval.value = "Aruba sport";
PARAMFIELD.CURRENTVALUES.ADD (Discreteval);
Adds the parameter to the collection of parameter fields.
Paramfields.add (Paramfield); The second parameter is the range value.
The Paramfield variable is set to the new value so that the previous settings are not overwritten.
Paramfield = new Parameterfield ();
Sets the name of the parameter field, which must match the parameters in the report.
Paramfield.parameterfieldname = "Customer ID";
Sets the start and end values of a range and passes the range to the parameter.
Rangeval.startvalue = 42;
Rangeval.endvalue = 72;
PARAMFIELD.CURRENTVALUES.ADD (Rangeval);
Adds the second parameter to the collection of parameter fields. Paramfields.
ADD (Paramfield);
Puts the collection of parameter segments into the viewer control. Crystalreportviewer1.parameterfieldinfo = Paramfields;
Here is my own application:
public void Onepage (Crystalreportviewer crystalreportviewer,int a)
{
Parameterfields paramfields = new Parameterfields ();
Parameterfield Paramfield = new Parameterfield ();
Parameterdiscretevalue discreteval = new Parameterdiscretevalue ();
The first parameter is a discrete parameter with multiple values. Sets the name of the parameter field, which must match the parameters in the report.
paramfield.parameterfieldname = "arc_i_id";
Sets a discrete value and passes it to the parameter.
discreteval.value = ID;
PARAMFIELD.CURRENTVALUES.ADD (discreteval);
Adds the parameter to the collection of parameter fields.
Paramfields.add (Paramfield);
Puts the collection of parameter segments into the viewer control.
crystalreportviewer.parameterfieldinfo = paramfields;
}
The first code has two parameter fields, and the second code has a parameter field.
I hope this article will help you with the ASP.net program design.