none
How to hide a subreport when there is no data to display RRS feed

  • Question

  • I'm using Visual Studio 2010 report designer and have datasets for my reports based on objects of my program. I'm having the error "Object reference not set to an instance of an object." in my localreport every time there is no data for my subreports and I can't figure out the cause for this problem. When I hide the subreports, all goes right. So, I would like to know if there is a way a subreport can tell to its parent report that there is no data in its datasource so the main report can hide the subreport or the row that contains the subreport.

    Thanks for any help.


    Codelines

    Tuesday, February 24, 2015 2:10 AM

Answers

  • I found a simple solution for this problem. Edit the report file in a xml text editor and set the row height for each subreport to zero. If there is data to display, the row grows; if there is no data, the row remains invisible.

    Codelines

    • Marked as answer by Codelines Saturday, February 28, 2015 4:40 PM
    Saturday, February 28, 2015 4:08 PM

All replies

  • I thought for a while that I could solve the problem creating a parameter in the main report and casting the first argument of my subreportprocesssing event handler to LocalReport and setting the parameter using the SetParameters method of the LocalReport object indicating when there was data to show or not. But this doesn't worked , the parameter value remains the same when I use it in expressions to change the visibility property of my subreports.

    Codelines

    Tuesday, February 24, 2015 11:49 AM
  • I found a simple solution for this problem. Edit the report file in a xml text editor and set the row height for each subreport to zero. If there is data to display, the row grows; if there is no data, the row remains invisible.

    Codelines

    • Marked as answer by Codelines Saturday, February 28, 2015 4:40 PM
    Saturday, February 28, 2015 4:08 PM