Click here to Skip to main content
15,891,680 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am taking the inputs by user in web application interface but I am not saving these values in db... I want to pass these values to parameters field of crystal report through controller or report generator get-report() method. for-example user inputs date-range and its manipulates all date inputs in controller method and displays filtered data on crystal report.

What I have tried:

i have formatted crystal report accordingly... filters or parameter fields are working fine for report viewer but i am not getting anyway to get user input and set-parameters in controller method accordingly...
any help ?????
Posted
Updated 19-Sep-17 15:45pm
v4

1 solution

Hi Sarah,

There is many examples available, but the method I use that works is;
C#
if(rptDoc.DataDefinition.ParameterFields.Count > 0)
{
    foreach(ParameterFieldDefinition crDef in rptDoc.DataDefinition.ParameterFields)
    {
    // Check for empty report name
    // Sub Reports will have a value, Main Report does not
    // Sub Report Parameters are passed by the Main Report
        if(crDef.ReportName == string.Empty)
        {
            object objValue = "What ever value I want to use";
            rptDoc.SetParameterValue(crDef.ParameterFieldName, objValue);
        }
    }
}

You can then run the report & show in a WebViewer or export to a stream and return as a PDF/Word/Excel etc

Kind Regards
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900