Skip to Content
author's profile photo Former Member
Former Member

How to set default value to a parameter in sub-report using .Net SDK


We have a main report and a sub-report. The sub-report has two parameters, one of them has a default value. The main report has only one parameter and it is linked to the non-default parameter in sub-report. When we try to load and export the main report using .Net SDK, we only pass the required parameter to main report. We don't want to pass the 2nd parameter to the sub-report since it should take its default value.

However the code throws a Missing Parameter exception, which is caused by the default parameter from the sub-report.

Is there a way to pass the default to the sub-report?


Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jul 20, 2016 at 06:34 PM

    Have you configured the parameter that contains a default as an Optional parameter? (This is an available option for Crystal 2008 and newer). If not, you need to do this. That way there should be no issues with the code if you don't give it a value other than the default.


    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Vinit Shete

      Thanks Vinit. I am able to loop through the subreports and assign them one by one.

      Now I ran into another issue. How can I tell if a parameter in main report is linked to a parameter in sub-report?

      var subReportNames =


      foreach (var subReportName in subReportNames)


      var defaultValuesSubReport = new Dictionary<string, string>();

      foreach (CrystalDecisions.ReportAppServer.DataDefModel.ISCRParameterField clientParameterFieldDefinition in cryRpt.ReportClientDocument.SubreportController.GetSubreport(subReportName.ToString()).DataDefController.DataDefinition.ParameterFields)


      foreach (var initialValue in clientParameterFieldDefinition.InitialValues)


      var discreetInitialValue = initialValue as CrystalDecisions.ReportAppServer.DataDefModel.ParameterFieldDiscreteValue;

      if (discreetInitialValue != null)


      defaultValuesSubReport.Add(clientParameterFieldDefinition.Name, discreetInitialValue.Value);

      //var defaultValue = discreetInitialValue.Value; //Use initial value anyway you would like to. In our case, we stored it and passed to our ExtJs UI to populate in the interface.




      foreach (var defaultValue in defaultValuesSubReport)


      cryRpt.SetParameterValue(defaultValue.Key, defaultValue.Value, subReportName.ToString());



Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.