Tip: Get report parameters as text from Crystal Reports in C#

I am starting a new set of posts presenting small code snippets in C# you could use when working with Crystal Reports in Visual Studio.

And the first one is “GetReportParamsAsText“. Very simple but very handy function which allows to include report parameters values in your ASP.Net page without actually displaying the report.
This version works only with Discrete Value parameters. 

/// Function returns list of paramaters descriptions with
/// associated values for specified report
public string GetReportParamsAsText(ReportDocument reportDocument)
    if (reportDocument == null) return "Report not specified";
    string result = "";
    string description;
    string valueText;
    ParameterDiscreteValue value;
    foreach (ParameterFieldDefinition prm
                  in reportDocument.DataDefinition.ParameterFields)
            if (prm.CurrentValues.IsNoValue) continue;
            if (prm.CurrentValues[0] is ParameterDiscreteValue)
                value = (ParameterDiscreteValue)prm.CurrentValues[0];
                if (description.StartsWith("Enter "))
                    description = description.Remove(0, 6);
                valueText = value.Value.ToString();
                valueText = "[not supported param type]";
            result += "<strong>" + description + "</strong> " + valueText + "
            // Ignore any errors
    return result;
This entry was posted in Crystal Reports and tagged , , . Bookmark the permalink.

Leave a Reply

  • About

    From being a junior developer all the way to Development Manager position, I was always interested in new technologies. Passionate speaker, IT junky, developer, architect, team lead, and development manager - many hats, one goal - making software better and closer to people’s needs. For the most part I am using my blog as a scratch pad, writing small articles on things which I came across, was asked about more then once, and which would otherwise require additional research again and again.

    View Serguei Dosyukov's profile on LinkedIn
  • Testimonials

    I’m a huge fan of this theme. I’ve got more than 90,000 pictures in my gallery3 running on a Ubuntu...


    The greydragon theme is fantastic. It’s clean, stable and feature rich. It took me a while to decide to move...


    I've been using this [theme] since the start. It is by far the most attractive, feature packed and stable of...



  • Categories