This article illustrates the method of assigning value of asp.net Crystal Report parameter fields in code. Share to everyone for your reference. The implementation methods are as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27-28 |
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); The parameterThe number segment collection is placed in the viewer control. Crystalreportviewer1.parameterfieldinfo = Paramfields; |
Here is my own application:
?
1 2 3 4, 5 6 7 8 9 10 11 12 13 14 15 |
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.