简体   繁体   中英

Crystal Report Parameter

I am new to C# and I am trying to view an already created crystal report using crystal report viewer. However I want users to be able to filter the result of the report based on some inputs from user end and I am not allowed to create these parameter fields in crystal report itself. Is it possible to programmatically pass the fields and values from c# ASP.net web form without having to declare these parameters in crystal report.

I have tried the following but it doesn't work:

        ParameterFields paramFields = new ParameterFields();
        ParameterField paramField = new ParameterField();
        ParameterDiscreteValue dv = new ParameterDiscreteValue();
        paramField.ReportName = "SiteDetailsFull.rpt";
        paramField.Name = "Site Name";
        dv.Value = DropDownList1.SelectedItem.Text;
        paramField.CurrentValues.Add(dv);
        paramFields.Add(paramField);
        aquaRptViewer.ParameterFieldInfo = paramFields;

You can't pass a parameter without declaring it in the report.

But you can use a formula to add your constraint and then pass it to report to get the data filter as you want.

Example:

formula = " FiledName =  Some filter date  ";
reportClass.RecordSelectionFormula = reportClass.RecordSelectionFormula + formula;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM