Example 3. Data filtering

Top  Previous  Next

In this example, we will show how to hide the "Data" band row depending on the given conditions. We will be using:

 

BeforePrint band event;
reference to the data source from a script.

 

Create a simple report having the following appearance:

 

scriptEvents1

 

Create a BeforePrint event handler for the band:

 

private void Data1_BeforePrint(object sender, EventArgs e)

{

  if (((Decimal)Report.GetColumnValue("Products.UnitPrice")) > 20)

    Data1.Visible = false;

}

 

In the given case, the band rows which have the unit price > 20 will be hidden:

 

scriptExample3

 

The same effect can be achieved by using the data filter which can be set in the "Data" band editor.