Phil Sandler
Phil Sandler

Reputation: 28016

Using a Custom Object with ReportViewer in an ASP.Net Project

I am trying to follow the instructions here: http://msdn.microsoft.com/en-us/library/ms251692(v=vs.110).aspx

However, my project is an MVC project, so I can't follow the steps exactly.

I am trying to use a custom object to provide data to a local ReportViewer report. I am converting a server-side report to local (rdl => rdlc). The report viewer control already works with the server report.

In the Dataset Properties page, in the Data source box, select global.

When I try to add a dataset, I get a dialog box asking for me to choose a data connection. If I cancel out of that, I am at the Dataset Properties page, but the data source drop down is empty. Using the Report Wizard takes me essentially down the same path.

I created a new WPF project to see if I had the same problems, and it worked pretty easily. It immediately gave me data source choices of database, object, service, and sharepoint. I realize the two controls (web and windows) are completely independent.

What am I missing? Is it even possible to use the ReportViewer in an MVC project (that also has aspx pages) and use a custom object to supply data?

Upvotes: 1

Views: 1428

Answers (2)

Phil Sandler
Phil Sandler

Reputation: 28016

For whatever reason, I was able to get this to work as expected by moving the rdlc file out of the web project and into a class library.

Upvotes: 4

Dimitar Tsonev
Dimitar Tsonev

Reputation: 3882

When you use the reportviewer control in local mode, you have to obtain the data manually through your code, not using the report designer. After that, you pass it to the ReportViewer as ReportDataSource objects. They have DataTable properties which is the actually data. You obtain datatables from the db, so this is pretty straightforward.

This article explains how this is achieved.

Upvotes: -1

Related Questions