This prior post provides an overview of reporting in your WinForms or WebForms application. This post details how to tie your report to data defined within your business objects.
See this prior post if you want to tie your report directly to data in the database.
In this example, the report built in this prior post is tied to a list of Customer business objects. The list of customer objects is defined in this prior post and summarized below:
In C#:
Customer class:
public class Customer
{
public int CustomerId { get; set; }
public string LastName { get; set; }
public string FirstName { get; set; }
public string EmailAddress { get; set; }
}
List of customers:
List<Customer> custList = new List<Customer>
{new Customer()
{ CustomerId = 1,
FirstName="Bilbo",
LastName = "Baggins",
EmailAddress = "bb@hob.me"},
new Customer()
{ CustomerId = 2,
FirstName="Frodo",
LastName = "Baggins",
EmailAddress = "fb@hob.me"},
new Customer()
{ CustomerId = 3,
FirstName="Samwise",
LastName = "Gamgee",
EmailAddress = "sg@hob.me"},
new Customer()
{ CustomerId = 4,
FirstName="Rosie",
LastName = "Cotton",
EmailAddress = "rc@hob.me"}};
In VB:
Customer class:
Public Class Customer
Public Property CustomerId As Integer
Public Property FirstName() As String
Public Property LastName() As String
Public Property EmailAddress() As String
End Class
List of customers:
Dim custList As New List(Of Customer) From
{New Customer() With
{.CustomerId = 1,
.FirstName = "Bilbo",
.LastName = "Baggins",
.EmailAddress = "bb@hob.me"},
New Customer() With
{.CustomerId = 2,
.FirstName = "Frodo",
.LastName = "Baggins",
.EmailAddress = "fb@hob.me"},
New Customer() With
{.CustomerId = 3,
.FirstName = "Samwise",
.LastName = "Gamgee",
.EmailAddress = "sg@hob.me"},
New Customer() With
{.CustomerId = 4,
.FirstName = "Rosie",
.LastName = "Cotton",
.EmailAddress = rc@hob.me}}
To Build a Data Source for a Report:
1) Display the report designer by double-clicking on the .rdlc file in the Solution Explorer.
2) Display the Data Sources Window (Data | Show Data Sources).
3) Click on the Add New Data Source button in the Data Sources Window toolbar.
4) Select to get the data from an Object and click Next.

5) Select the business object that defines the fields for the report and click Finish.

Your data source is then created and shown in the Data Sources Window.
To Build a Dataset for a Report:
A report is tied to a data source through a dataset. A dataset defines the data fields available to the report. You define a dataset based on a data source (created in the steps above).
This term "dataset" should not be confused with an ADO.NET dataset. This is not the same thing. In this context, a "dataset" is simply a set of data that can be used on a report.
1) Display the report in the designer by double-clicking on the .rdlc file in the Solution Explorer.
2) Display the Report Data Window (View | Report Data).
NOTE: If you do not see the Report Data menu option, ensure that the report designer is the active window.
3) Select New | Dataset from the Report Data window toolbar.
This creates a dataset that is accessible from the report.
4) Enter the name of the dataset, select the data source to use as the source of data for the dataset (defined in the prior set of steps), and select the data object within the data source to tie to the report.
The fields available to the report are then shown:

NOTE: By my programming convention, I name the report’s dataset "XXXDataSource" so as not to be confused with any typed dataset in the project.
The fields also appear in the Report Data window:

NOTE: To view the Report Data window, ensure that a report is the active Window in design mode. Then select View | Report Data.
To Display Data from the Data Source on the Report:
1) Display the report in the designer by double-clicking on the .rdlc file in the Solution Explorer.
2) Hover over a cell in the data row, click on the field list (circled in red in the image), and select the field to display in the cell.

3) Repeat for each cell in the table.
4) To add fields from the dataset that are not already shown in the table, drag the field from the Report Data Window and drop it in the table.
5) Write the code to populate the data source.
When you tie a report directly to a database, the data is automatically retrieved when you run the report. When you tie a report to a set of business objects, you need to populate the underlying data source.
In C#:
private void ReportWin_Load(object sender, EventArgs e)
this.customerBindingSource.DataSource = Customers.RetrieveList();
this.reportViewer1.RefreshReport();
End Sub
In VB:
Private Sub ReportWin_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Me.CustomerBindingSource.DataSource = Customers.RetrieveList
Me.ReportViewer1.RefreshReport()
End Sub
This code assumes that a static/shared method in the Customers class called RetrieveList retrieves the list shown at the top of this post.
Use this technique any time you want your report to pull its data from your business objects.
Enjoy!
EDIT 2/18/11: Added a note with details on viewing the Report Data window.