Using Object data source in ASP.NET 4 ReportViewer

Memi picture Memi · Nov 22, 2010 · Viewed 10.3k times · Source

OK, I think I'm getting mad here... I thought this should be super simple, but I just can't figure out how to do that.

This is what I'm trying to do: I want to create an rdlc report using the ReportViewer control in ASP.NET 4 (VS 2010), and, as its datasource, use a class with some properties. I tried everything I can think of, but I just can't figure this out. All the docs I found state that the object should appear in the DataSource pane of the website, but I can't make it appear there. I would like the fields of the class to appear in the report desiger so I can use them - but I can't do that either. Using the designer, I can only define new dataset - I don't want to use dataset, but business objects!

So - how can I do that? Do I have to use some kind of DataSource control? How can I make the report designer know about the business object?

Thanks!

Memi

Answer

hope_is_grim picture hope_is_grim · Apr 26, 2011

did you follow this tutorial?
everything you must do is:

  • define your DTO classes or generate it using EF4 (for example)
  • define your business classes with some methods (like GetAll...)
  • build your solution (that's important)

now from your report designer you can choose methods from business classes as dataset and drag and drop field from the DTO classes
when you choose that report to display in the reportviewer, the datasource object will be added for you