locked
Report Viewer RRS feed

  • Question

  • User-2097567671 posted

    Hi,

    I have a table in my report.  I am trying to show/hide a merged textbox (the entire row) in the table based on whether or not any data from my query is populated in the table.

    For instance:
    If my table contains data, I want the "No data available" textbox to stay hidden.
    However, if my table does not contain any data, I want my "No data available" textbox to be visible.

    Here is what I have so far in the "Visibility" tab of the "No data available" textbox in my table:  =Iif(Fields!Status.Value = "", e.style.visibility = "visible", e.style.visibility = "hide")

    Does anyone know how to do this?

    Thanks.

    Tuesday, August 13, 2013 9:50 AM

Answers

  • User281315223 posted

    If memory serves, I believe there is a COUNTROWS function that you can use to get the number of rows that are available provided a specific dataset : 

    = IIF(COUNTROWS("YourDataSet") > 0, False, True)

    or you could probably directly set the Visibility property to a boolean itself : 

    Visible = COUNTROWS("YourDataSet") <= 0

    (It's been quite some time since I have worked with SQL Reporting)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 13, 2013 10:41 AM
  • User306743125 posted

    You might have to do the COUNT on a number field, as opposed to Text..

    =IIF(COUNT(Fields!YourField.Value) > 0, False, True)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 13, 2013 10:53 AM
  • User488649576 posted

    Hi,

    A subreport is a report item that you add to a report as a layout element. A subreport points to a different report and displays inside the body of a main report as an subreport instance. The subreport can use different data sources than the main report. Although a subreport can be repeated in data regions by using a parameter to filter data in each instance of the subreport, subreports are typically used with a main report as a briefing book or as a container for a collection of related reports. Each instance of a subreport switches context for report processing between the main report and the subreport. For reports that use many instances of subreports, consider using drillthrough reports instead. For more information, see Subreports (Report Builder and SSRS).

    by:http://technet.microsoft.com/en-us/library/bb630404.aspx

    and take a look on this link: http://technet.microsoft.com/en-us/library/dd239314.aspx

    for How to create a sub report :

    http://www.codeproject.com/KB/reporting-services/ReportingServices.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 15, 2013 5:49 AM

All replies

  • User306743125 posted

    You could create a Group. Then do a row count in your visibility expression;

    if row count = 0 hide else visible

    Tuesday, August 13, 2013 10:16 AM
  • User-1225287840 posted

    Refer this,

    How do I change visibility of a textbox inside a ReportViewer?

    http://stackoverflow.com/questions/9163978/how-do-i-change-visibility-of-a-textbox-inside-a-reportviewer

    Tuesday, August 13, 2013 10:18 AM
  • User-2097567671 posted

    Thanks for your reply!

    I am new to report viewer.  What syntax do I use for your recommendation?

    Thanks.

    Tuesday, August 13, 2013 10:19 AM
  • User-2097567671 posted

    Thanks for your reply!

    I have tried to follow the recommendation on your link, but it doens't seem to be working. 

    This is what I have so far:  =Iif (First(Fields!VendorID.Value) = "", False, True)

    I also tried switching the True and False variables.  When I did that, the textbox would show only when there is data available.

    Do you know the syntax for counting the rows as mentioned by the responder above?

    Thanks.

    Tuesday, August 13, 2013 10:36 AM
  • User281315223 posted

    If memory serves, I believe there is a COUNTROWS function that you can use to get the number of rows that are available provided a specific dataset : 

    = IIF(COUNTROWS("YourDataSet") > 0, False, True)

    or you could probably directly set the Visibility property to a boolean itself : 

    Visible = COUNTROWS("YourDataSet") <= 0

    (It's been quite some time since I have worked with SQL Reporting)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 13, 2013 10:41 AM
  • User306743125 posted

    You might have to do the COUNT on a number field, as opposed to Text..

    =IIF(COUNT(Fields!YourField.Value) > 0, False, True)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 13, 2013 10:53 AM
  • User-2097567671 posted

    Thanks for your reply! Your first recommendation seems to work correctly.

    However, it seems to think that COUNTROWS=0 all the time regardless of whether or not there are rows available.  This leads me to believe that maybe it is counting the rows before the dataset is actually bound?

    Does that make sense?

    Tuesday, August 13, 2013 11:08 AM
  • User-2097567671 posted

    One caviat here that I neglected to mention earlier.  My table is in a SubReport.  However, I didn't think that mattered as much because both the table and the textbox are in the same SubReport.

    Would this make any difference?  Everything else in the SubReport is populating correctly.

    Tuesday, August 13, 2013 11:15 AM
  • User-2097567671 posted

    It just dawned on me why this isn't working.

    My parent report contains multiple subreports.  My parent report makes a single query to the database and then each sub report filters that dataset based on each BizID.

    So......what I need to do is NOT count the rows in the dataset, but instead check the actual table to see if there are any rows in it.

    Does this make sense?

    Tuesday, August 13, 2013 1:32 PM
  • User-734925760 posted

    Hi mattcase,

    By the description, we will get data from a DataTable.

    Please try to refer to the code as the following:

    =Iif (First(Fields!VendorID.Value) = "", False, True)

    Update to:

    =IIF(First(Fields!VendorID.Value, "DataSet1")="",true,false)

    More information about Common Expressions for Reports, please try to the following link:

    http://msdn.microsoft.com/en-us/library/ms251668(v=vs.90).aspx

    Best Regards,

    Michelle Ge

    Wednesday, August 14, 2013 6:44 AM
  • User-2097567671 posted

    Thank you for your reply.  However, I have already tried this approach.

    My problem is that my "DataSet1" that you called for is a large dataset that covers several businesses.  Each Subreport filters that "Dataset1" by BizID.  So when I implement it as you are suggesting, it considers the entire dataset and not the filtered dataset.  Does that make sense?

    Thanks.

    Wednesday, August 14, 2013 9:26 AM
  • User488649576 posted

    Hi,

    A subreport is a report item that you add to a report as a layout element. A subreport points to a different report and displays inside the body of a main report as an subreport instance. The subreport can use different data sources than the main report. Although a subreport can be repeated in data regions by using a parameter to filter data in each instance of the subreport, subreports are typically used with a main report as a briefing book or as a container for a collection of related reports. Each instance of a subreport switches context for report processing between the main report and the subreport. For reports that use many instances of subreports, consider using drillthrough reports instead. For more information, see Subreports (Report Builder and SSRS).

    by:http://technet.microsoft.com/en-us/library/bb630404.aspx

    and take a look on this link: http://technet.microsoft.com/en-us/library/dd239314.aspx

    for How to create a sub report :

    http://www.codeproject.com/KB/reporting-services/ReportingServices.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 15, 2013 5:49 AM