VB.Net: How to use an Object data source in report (.rdlc)

坚强是说给别人听的谎言 提交于 2019-11-29 08:39:16

From your description and accompanying code, there are no properties in the ReportData class. If I reckon well, that class is supposed to be generating the IEnumerable you want to display on the report.

If that's the case, you'll have to select the Employee class as the DataSource in the wizard. This will allow you to display the data on your report.

I'll work on a quick project and add it to this answer in a moment.



Edit 1

How to Bind a Class to a Report

Visual Studio 2008

  1. Open the report in Design View.
  2. Select from the menu bar Data > Show Data Sources
  3. Click Add New Data Source on the Data Sources window.
  4. Select Object and click Next.
  5. Browse the solution tree and select the class you want to bind to.
    In your case, you bind to the Employee class.
  6. Click Next and then Finish.


Visual Studio 2010

  1. Open the report in Design View.
  2. Select from the menu bar View > Report Data
  3. Click New > Dataset... on the Data Sources window.
  4. Enter a name for the dataset (e.g. Employee)
  5. Create a New Data source or select an existing data source.

    Creating a New Data source

    • Select Object and click Next.
    • Browse the solution tree and select the class(es) you want to bind to.
    • Click Finish.


After binding a class to the report, go ahead and design your report as usual.


Edit 2

I uploaded a sample project for you. Here's the link.
If you need further clarification, please notify me so I give you a step by step procedure on how to replicate the project.

I had the same problem. I had to add a Data Source (Object Type) to my presentation layer that pointed to my Object in the Business layer (collection with property class). I created the report (.rdlc) in the presentation layer and pointed it to the Data Source and everthing working fine. This was the only way I found to expose the field properties to the report. At runtime I bind the report datasource to the collection. I like to design a "flat" collection in the business layer, process the data and send it to the rdlc keeping the report as "dumb" as possible.

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