How do I display 'No data available.' when there are no rows to show on the report?

杀马特。学长 韩版系。学妹 提交于 2019-11-28 09:03:33

You could set the property NoRowsMessage available on the report's table control like this:

  • Select the Tablix control and press F4 to view the Properties pane.
  • Find the NoRowsMessage property and set the value to whatever message you'd like.
  • You can also to format the message using the Font and TextAlign properties.

Here are some examples of what the report will look like under various settings:

Further Reading: Here is a Technet article on how to Set a No Data Message for a Data Region

Avoid NoRowsMessage and build your own conditional empty row

One problem (or feature if that's what you want) with NoRowsMessage is that it'll literally replace the entire table with just a plain old message string.

Which provides a relatively counter-intuitive end user experience in my opinion. Normally when no data is found by a system, we'd like to know something about what data was being looked for and what it would have looked like.

Instead, based off how to keep the structure of the Tablix when there is no data to show, you can do the following:

  1. Insert New Header Row, outside the group and above the details record.

  2. Right click on the side of the new row and Set Row Visibility

  3. Set Visibility to the following expression which will count the rows inside the current Tablix and only set Visibility to True if there is no data.

    =CountRows() > 0
    

  4. Optionally, merge the cells and add your own message or just display an empty row

Here's a comparison of how the various options will render:
(pick whichever look you think best fits your data and use case)

Right-click on whatever databound element(s) you are using in the report and there should be a property NoDataMessage There are a host of options there but the Caption is the first element I would look at.

No Rows Message does not seem to be listed in the properties for SQL 2005 SSRS, simply just the NoRows property. How do we set the NoRowsMessage within the user interface for 2005? Unfortunately Right Clicking on the components in layout did not surface the NoRowMessage property to configure. After sometime working with the components on my report I found that setting the NoRows property of the Table did not work as expected, but by setting the NoRows value of the List that the table was part of. When no data is returned for the parameters passed the List now displays text to the user instead of the table.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!