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")
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?
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.
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.
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?
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).
Member
115 Points
582 Posts
Report Viewer
Aug 13, 2013 09:50 AM|mattcase|LINK
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.
reportviewer
Participant
1848 Points
897 Posts
Re: Report Viewer
Aug 13, 2013 10:16 AM|Basquiat|LINK
You could create a Group. Then do a row count in your visibility expression;
if row count = 0 hide else visible
reportviewer
Participant
1130 Points
349 Posts
Re: Report Viewer
Aug 13, 2013 10:18 AM|sridhar_rs|LINK
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
reportviewer
Thank you very much,
Please if my reply helped you.
Member
115 Points
582 Posts
Re: Report Viewer
Aug 13, 2013 10:19 AM|mattcase|LINK
Thanks for your reply!
I am new to report viewer. What syntax do I use for your recommendation?
Thanks.
reportviewer
Member
115 Points
582 Posts
Re: Report Viewer
Aug 13, 2013 10:36 AM|mattcase|LINK
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.
reportviewer
All-Star
114593 Points
18503 Posts
MVP
Re: Report Viewer
Aug 13, 2013 10:41 AM|Rion Williams|LINK
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 :
or you could probably directly set the Visibility property to a boolean itself :
(It's been quite some time since I have worked with SQL Reporting)
reportviewer
Participant
1848 Points
897 Posts
Re: Report Viewer
Aug 13, 2013 10:53 AM|Basquiat|LINK
You might have to do the COUNT on a number field, as opposed to Text..
reportviewer
Member
115 Points
582 Posts
Re: Report Viewer
Aug 13, 2013 11:08 AM|mattcase|LINK
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?
reportviewer
Member
115 Points
582 Posts
Re: Report Viewer
Aug 13, 2013 11:15 AM|mattcase|LINK
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.
reportviewer
Member
115 Points
582 Posts
Re: Report Viewer
Aug 13, 2013 01:32 PM|mattcase|LINK
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?
reportviewer
All-Star
18232 Points
2199 Posts
Re: Report Viewer
Aug 14, 2013 06:44 AM|Michelle Ge - MSFT|LINK
Hi mattcase,
By the description, we will get data from a DataTable.
Please try to refer to the code as the following:
Update to:
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
reportviewer
Member
115 Points
582 Posts
Re: Report Viewer
Aug 14, 2013 09:26 AM|mattcase|LINK
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.
reportviewer
Member
490 Points
114 Posts
Re: Report Viewer
Aug 15, 2013 05:49 AM|DemiWu|LINK
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
reportviewer