Last post Aug 15, 2013 05:49 AM by DemiWu
Aug 13, 2013 09:50 AM|mattcase|LINK
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.
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?
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
Aug 13, 2013 10:18 AM|sridhar_rs|LINK
How do I change visibility of a textbox inside a ReportViewer?
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?
Aug 13, 2013 10:36 AM|mattcase|LINK
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?
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 :
= 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)
Aug 13, 2013 10:53 AM|Basquiat|LINK
You might have to do the COUNT on a number field, as opposed to Text..
=IIF(COUNT(Fields!YourField.Value) > 0, False, True)
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?
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.
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?
Aug 14, 2013 06:44 AM|Michelle Ge - MSFT|LINK
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)
More information about Common Expressions for Reports, please try to the following link:
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?
Aug 15, 2013 05:49 AM|DemiWu|LINK
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).
and take a look on this link:
for How to create a sub report :