fyiReporting reports tutorial 2/2 (Parameters)

14 May

Part 1/2 (Intro)
Part 2/2 (Paramters)

If you want print in WPF please view my new WPF-Printing Library

In addition to the first part of the tutorial I will explain in this second part the usage of parameters.

The text that should appear in the body and the header can be made static or dynamic. To create a bill it is smarter to create it dynamic, because the recipient of the bill is every times another person. Such data is loaded into the report via parameter. To create a parameter you should double click in the footer section. In the parameter section you can add the parameter you need. Give it a name and a data-type. Now parameters can be used in textFields. To use this parameters you should write into the textBox following string “=Parameters!nameOfParameter.Value”.

As you can see,after opening the .rld file with fyiReporting Designer, the page header part of the report contains some labels that contains some strange strings like: =Parameters!Firma.Value.
Because it happens that e.g an invoice is send every times to another company the label containing the company name has to be different.
The parameter in the example above is used to display the Company name (Firma).

In order to display the value of the parameter at runtime, you have to write some lines of code:

ReportViewer reportViewer = new ReportViewer();

private ReportParameter loadReportParameter()
    ReportParameter parameters = new ReportParameter[1];
    parameters[0] = new ReportParameter("Firma", "String containing the name of the company");
    return parameters;

The tricky thing of using parameters is, that you have to initialize every single parameter of the report with a corresponding value, otherwise you will receive an error when you try to load the report. Unfortunately the error message that appears is not so clear as expected. Therefore, if more than one parameter is missing you will not exactly now which parameter you have not initalized. A hint is to add one parameter with the report designer and add the corresponding parameter to the ReportParamter array in the loadReportParameter() method.

Very useful is if you use following line of code into your C# class:

ReportParameterInfoCollection reic = reportViewer.LocalReport.GetParameters();

here you can see at debugging time the number of parameters that the .rld file expects.



Posted by on May 14, 2010 in C-Sharp, Printing, Reporting



4 responses to “fyiReporting reports tutorial 2/2 (Parameters)

  1. Sandeep

    May 18, 2010 at 12:05

    Hey great article for developing reports using fyireporting in windows applications.

    Can you please help me to do the same in

    Thanks and Regards

    • michaelmairegger

      May 18, 2010 at 22:58

      Thanks for the compliment.
      Unfortunately I have never programmed in ASP.NET.
      In fact that ASP.NET webpages can be programmed in C# I think that it should work in the same way.

      • axe

        January 19, 2011 at 02:37

        reportviewer does not work with web applications. So, I refered rdiasp.dll .. still cannot find proper report viewer..:(

  2. Arnaldo Rafael Gonzalez Jimenez

    July 3, 2014 at 04:16

    Hi, great post.. one question.. i have mysql database whit some tables one of this table java one row Type LONGTEXT in this row i have a full String info of one XML File inserted from VB.NET my question is i can use fyiReporting to read this table and get the XML and use for reporting?


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: