Deborah's Developer MindScape

         Tips and Techniques for Web and .NET developers.

December 15, 2010

Reporting in .NET

Filed under: C#,Reporting,VB.NET @ 2:02 pm

Most business applications require some type of reporting. Why bother with all of the CRUD (create, review, update, delete) if there is no reporting on all that data?

With .NET, there are several reporting options and features. This set of posts focuses on two features:

  • Report file: An installed template in Visual Studio for building the layout for a report.
  • ReportViewer: A control in the toolbox that can be added to a form for displaying the report to the user.

The example below provides an overview of building the "world’s simplest report". In building the "simplest" report, there are still a very large number of steps. So this post provides an overview and other referenced posts provide detail.

To Create a Report:

1) Add a report file to your project.

Select Project | Add New Item, click on Reporting under Installed Templates on the left and then select Report (or Report Wizard if you want to use the Wizard) in the middle.

NOTE: Though using the Report Wizard could arguably be the best approach when building the "world’s simplest report", when I first starting building reports with these tools I found the Wizard to be confusing (DataSource, DataSet, Row group, Column group, etc) . So for clarity, these posts walk through the manual steps.


Clicking Add adds the .rdlc file to your project. In this example, the report file is named Customers.rdlc.

2) Build the report layout using the tools in the toolbox. (View | Toolbox)

See this link for more information on building the layout for a report.

3) Tie the report layout to your data using the tools in the Report Data window. (View | Report Data)

When you build reports within Visual Studio, there is no mechanism for previewing the report with its data. You have to build your own user interface for displaying the report.

To Display a Report:

1) Add a form to your project.

NOTE: You can add a Windows Form or a Web form. This example uses a Windows Form.

2) Add the Report Viewer control from the toolbox to the form. (View | Toolbox)


You may want to dock the Report Viewer control within the parent container so the report fills the entire form.

3) Tie your report to the Report Viewer control.

The easiest way to tie your report to the Report Viewer is to use the Report Viewer’s smart tag:


Select the name of the report from the Choose Report drop down list.

4) Tie your dataset to the Report Viewer control.

The easiest way to tie your report dataset to the Report Viewer is to use the Report Viewer’s smart tag and select Choose Data Sources. Then select the data source defined in Step 3 of "To Create a Report".


5) Set the new form as your startup form if you want to run the report directly when launching your application for testing purposes.

See this post for instructions on setting a form as a startup form.

Otherwise, add navigation in your application that allows the user to navigate to the report either through a link, menu option, toolbar icon, or other mechanism.

The resulting report looks something like this:


Use this technique any time you need to add reporting to your application.


1 Comment

  1.   ELW — December 16, 2010 @ 9:18 am    Reply

    Hi, nice to read your article.

    I think use .rdlc file is quite good, btw how can I show image from my table (dataset)? for example, how to show a photo of one of the customer, Cotton.

    In my opinion, using this report is quite difficult then using crystal report if I make another layout (not like this common tabular datagridview style).

    How can I make layout only in two columns and four rows for each customer. The first colum is a photo of my customer and the second contains last and first name, email and last purchase date (4 rows).

    I will appreciate any suggestion.

RSS feed for comments on this post. TrackBack URI

Leave a comment

© 2021 Deborah's Developer MindScape   Provided by WPMU DEV -The WordPress Experts   Hosted by Microsoft MVPs