Category / Section
How to set and display No Data Message for data region items in ReportDesigner?
2 mins read
To specify custom text and show in a data region that has no data, set the NoRowsMessage property for a table, chart, and subreport report items. The following steps help you to create and preview the No Data Message report based on the dynamic value in WPF Report Designer.
- Create a new report, add embedded datasource and dataset. The following query adds the Department table from the AdventureWorks sample database.
SELECT [Department].[DepartmentID] ,[Department].[GroupName] ,[Department].[ModifiedDate] ,[Department].[Name] FROM [HumanResources].[Department] WHERE [HumanResources].[Department].[DepartmentID] = @DepartmentID
To set the NoRowsMessage for tablix, matrix, chart, or list
- Draw a table or chart report item and add the fields to the table from the report data explorer by expanding Dataset (Dataset1).
- In the Design area, click the table or chart on the design surface to select it. The properties pane displays with applied properties for the selected report item.
- In the properties grid, type the custom text that you want to display as a message in the NoRowsMessage property field. You can also set the dynamic value to it based on the Expression through ‘Expression Editor’ dialog.
- Here, query parameter DepartmentID is used to filter the data in runtime to showcase NoRowsMessage.
- You can customize the font and alignment properties of NoRowMessage with the help of property grid.
To set the NoRowsMessage for a subreport
- Create a report parameter named ‘DepartmentID’ with text datatype in SubReport.
- In the main report design view, drag and drop the subreport. Click the Subreport property, select the Parameters option, and then click the Add button to specify the parameter detail. In Label textbox, specify the Parameter name created in Subreport. In Value textbox, specify the data field value to filter data in Subreport.
- In the main report, click the subreport on the design surface to select it. The property pane displays the applied properties for the selected item.
- In the properties grid, type the custom text that you want to display as a message in the NoRowsMessage property field. You can also set the dynamic value to it based on the Expression through ‘Expression Editor’ dialog.
Preview the report
Preview the report to render the data region or subreport items in the ReportViewer based on the report parameter dynamic value as follows.
Please download the report for no data message here