Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Blogs | Beginners
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Safari Books Online
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » Reporting Services » Getting Started with ReportViewer Control

Getting Started with ReportViewer Control


I could not be more happier when I saw the ReportViewer control as a part of Visual Studio 2005 controls. This article is an introduction to the ReportViewer control and how to write a simple report using the ReportViewer control in Visual Studio 2005.

Author Rank:
Total page views :  19218
Total downloads : 
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
Become a Sponsor

If you have written any reporting applications in .NET, you may be familiar with Crystal Reports and/or Microsoft SQL Server Reporting Services.

The ReportViewer control is a new addition to Visual Studio 2005, which is actually a Reporting Services component. This control has two versions - Windows Forms version and Web version. As you may presume, Windows Forms version is used to write reporting applications in Windows Forms applications and Web version is used to write ASP.NET Web applications.

Report Processing Modes

The ReportViewer control supports two report processing modes - local and remote.

In local processing mode, the ReportViewer control runs within the client application and the report processing is performed as a local process on the client machine where actual application is running.

In remote processing mode, the ReportViewer control runs on a SQL Server 2005 Reporting Services report server. In this mode, the ReportViewer control is used to view the report that is already generated on the server. All processing from data retrieval to report rendering is performed on the report server. To use remote processing mode, you must have a licensed copy of SQL Server 2005 Reporting Services.

Both Windows and Web controls can be configured to run in local processing mode or remote processing mode.

Namespace and Assembly

The ReportViewer control assemblies for Windows Forms and Web Forms versions are  Microsoft.ReportViewer.WinForms and Microsoft.ReportViewer.WebForms respectively. You must have to import the namespace in your application before start using the ReportViewer control. If you use add the ReportViewer control by dragging and dropping from the Toolbox, the namespace and assembly references are added for you automatically.

Create a Simple Report

Now let's create a simple report using the ReportViewer control. In this application, I will load data from a SQL Server database to generate reports.

  1. Create a Web Application using Visual Studio 2005

  2. Drag and drop a ReportViewer control from Toolbox to the Web page

  3. Right click on the Project in Solution Explorer and select Add New Item menu item and select DataSet from the list and keep DataSet1.xsd as name.

  4. The next screen is TableAdapter wizard, which asks you question about your database connection and SQL queries where you want data to be selected from. Just follow the wizard steps one by one and you will end up seeing DataSet in designer mode with your table name and columns. Close the designer.

  5. Now right click on the Project again and select Add New Item and select Report from the available items and click Add button. See Figure 1.



    Figure 1. 

  6. It will add Report.rdlc file to your project and will open the report designer, which looks like Figure 2. As you can see in the left side, you will see your DataSet.



    Figure 2. 

  7. Now you can expand your DataSet and drag whatever column you want in the report to the report designer. I select three columns in Figure 3. 



    Figure 3.

  8. Now if you right click and select Properties on a TextBox, you will see Figure 4, where you can apply settings like visibility, navigation, format, font, and sorting. For now, you can say OK on this dialog. I will discuss these properties in more details in my following articles. 



    Figure 4. 

  9. Now go to the Web page and click the smart tag on ReportViewer and select Report.rdlc from the list. See Figure 5.



    Figure 5. 

  10. That's it. Now if you run the application, you will see report. You can navigate through records, and export it to Excel or PDF using the Export option.

Summary

The ReportViewer control available in Visual Studio 2005 makes reporting easier for .NET developers. This article was a basic introduction to ReportViewer control and how to get started with it. Now having Reporting Services component available in Visual Studio, you don't have to deal with Crystal Report, its distribution and licensing issues.


Login to add your contents and source code to this article
 About the author
 
Mahesh Chand
Mahesh is a software developer with over 13 years of experience building systems for Financial and Banking, Engineering & Architectural, Imaging, Construction, Biological & Pharmaceuticals, Healthcare and Education industries. His expertise is Windows Forms, ASP.NET, Silverlight, WPF, WCF, Visual Studio 2010, SQL Server, and Oracle. If you are looking for a Sharepoint, Windows Forms, ASP.NET, WPF, Silverlight, C#, VB.NET, Oracle, and SQL Server Consultant in Philadelphia area or remote location, drop me a line at MAHESH [AT] C-SHARPCORNER [DOT] COM.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
SQL and .NET performance profiling in one place
Investigate SQL and .NET code side-by-side with ANTS Performance Profiler 6, so you can see which is causing the problem without switching tools.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
60 FREE UI Controls from DevExpress
Register for your FREE copy on over 60 free presentation controls from DevExpress - Absolutely Free-of-Charge without any royalties or distribution costs. Visit Devexpress.com/60 today. Free controls include advanced lists box, dropdown calendar, rich text edit, spin edit, tab control and so much more!

DevExpress engineers feature rich presentation controls and reporting tools for WinForms, ASP.NET, WPF, and Silverlight. Our technologies help you build your best, see complex software with greater clarity and deliver compelling business solutions for Windows and the web in the shortest possible time.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010
Visualize your workspace with new multiple monitor support, powerful Web development, new SharePoint support with tons of templates and Web parts, and more accurate targeting of any version of the .NET Framework. Get set to unleash your creativity.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Developer-Ready ASP.NET 2.0 Web Hosting with 3 MONTHS FREE
Now supporting .NET 3.0 Framework with Windows Workflow Foundation, Windows Communication Foundation (WCF), Windows Presentation Foundation (WPF), windows CardSpace (WCS)! Providing more flexibility for Developers with Web Services Support and a User/Permission Manger. Also supporting MS SQL 2005/2000 with Real-Time Backups, FREE Automated Attach .MDF Tool, FREE SQL Restore and Shrink SQL DB Tools, and SQL
Read the Top 10 Books for Microsoft Developers, 15 Days FREE
Read the Top 10 Books for Microsoft Developers, 15 Days FREE
Try Safari Books Online - 15 Days FREE + 15% Off for 1 Year
Try Safari Books Online - 15 Days FREE + 15% Off for 1 Year
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Nevron Chart
Become a Sponsor
 Comments
using ReportViewer Controls in a jsp application calling Reporting Services using Web Services by abhijit On May 29, 2007
Hi, I am invoking RS web services to render reports, using Apache Axis to generate stub classes from Reporting Service WSDL. Please let me know if I can integrate Report Viewer control in the jsp where I am writing the report output. Else do I have to create my own custom tags simulating ReportViewer functionality.
Reply | Email | Delete | Modify | 
Re: using ReportViewer Controls in a jsp application calling Reporting Services using Web Services by Mahesh On June 4, 2007
ReportViewer control is available in Visual Studio only. I have no idea how to use it in JSP.
Reply | Email | Delete | Modify | 
Question regarding reportviewer control by Kevin On June 14, 2007
Hello, this is very insightful. How would you do this if the report requires a parameter before it can be rendered. I understand that the reportviewer simply loads a completed dataset and that it is the apps responsibility to preproces the dataset before it is passed to the reportviewer control, but I can't find how this is accomplished. Thx.
Reply | Email | Delete | Modify | 
Thank you for the post...I got a question by Jose On July 17, 2007
If i got an application the uses a database and displays de data in a windows form. How can I pass the current displayed data to a report. Let say that de database contains customer iformation and I just want to print a particular record in the database, not all of them. By the way your post helped me alot to understand de concept of how the reportviewer worked Thank you. With the method described in your post I am able to print out all the records in the batabase, I just want to be able to select the one I want to sent to the report, or send the one that is currently displayed by the windows form. Thank you in advance for your response
Reply | Email | Delete | Modify | 
Re: Thank you for the post...I got a question by Mahesh On July 19, 2007

Read my article

http://www.vbdotnetheaven.com/UploadFile/mahesh/reportfromDataSet05102007235707PM/reportfromDataSet.aspx

It tells you how to bind a DataSet. Now, you can create your own DataSet in your code and pass it to that. This DataSet can be filtered for whatever records you want to display on the report before passing it to the Report.

You can use RowFilter, Select and other methods of DataSet.Tables(0) to filter the rows.

If you want to send only selected rows on a Windows forms to a report, you create a new DataSet (using YourDataSet.Clone() method to create a new DataSet) and add only rows you want to send to the report.

 

Reply | Email | Delete | Modify | 
Class for exporting multiple reports??? by bret On September 10, 2009
Do you by chance have a class for exporting multiple reports using the report viewer.
Thanks
Reply | Email | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2010.8.14
 © 2010  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.