Visual Studio 2010 Local SSRS Report (.rdlc) with Object Data Source

后端 未结 6 1241
谎友^
谎友^ 2020-12-16 11:59

I\'ve created more projects using ReportViewer 2005 and 2008 in local processing mode than I can count on my hands. All Visual Studio 2005 or 2008 ASP.NET web forms projects

6条回答
  •  长情又很酷
    2020-12-16 12:33

    The short answer: Yes you can use object data sources in RDLC 2008 (it's just not intuitive). Here's how:

    Open your RDLC page (in [Design] view). After a moment, the "Data" tab will appear at the top of Visual Studio. Select "Add New Data Source", choose "Object", and Next. From there, you will be able to see the list of objects you can bind to. Pick your DTO/Business Object/whatever from your project and hit Finish. In the Report Data sidebar tab on the left side of Visual Studio, you will see your object added. Copy the datasource name it generated (it'll be something like "MyProject_MyObject").

    Now in your controller, you can pull an IEnumerable of that DTO/BusinessObject and pass it in as the data parameter and your datasource name like this (sorry, no VB syntax):

    ReportDataSource reportDataSource =
                new ReportDataSource("MyProject_MyObject", myIEnumerable);
    

提交回复
热议问题