Building Reports Using ASP.NET and Crystal Reports - Part 4: Dynamic Grouping
page 1 of 9
Published: 18 Aug 2009
Abstract
In this fourth part of the series, Vince Varallo examines the creation of an employee report and demonstrates the usage of Crystal Reports object model to change the grouping fields and manipulate the properties of the group at runtime to show or hide sections, reset the page number, or insert a page break using Visual Studio 2008. He provides a step-by-step analysis of each procedure with the help of relevant screen shots and source code.
by Vince Varallo
Feedback
Average Rating: 
Views (Total / Last 10 Days): 84447/ 131

Introduction

This is the fourth article of a series that uses ASP.NET and Crystal Reports to build reports using the Adventure Works Sample Database. Before reading this article it would be helpful to have read Part 1, Part 2, or Part 3, but it is not required. This article focuses on creating an ASP.NET web application that allows a user to dynamically change the grouping on a report without having to create a new report file. How many times have you created a report for a user and once they start using it they ask you to give them the same data just grouped a different way?  You may want to show a count of records or a summary in the group footer. This is especially true when working with dates. Users ask to see the same data by year, quarter, month, or week. You could create a separate report file for each group, but this can be difficult to maintain. Instead, Crystal Reports for .NET allows you to manipulate the report at runtime so the user can change the group themselves without creating multiple copies of the report.

Before you begin you will need to have installed Visual Studio 2008 with Crystal Reports for .NET.  The samples are written in Visual Studio 2008, but they will work with Visual Studio 2005 as well.  You also will need to download the AdventureWorks sample database from http://msftdbprodsamples.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=18407 for SQL Server 2008. Download and install the SQL2008.AdventureWorks_All_Databases.x86.msi file. If you do not have SQL Server 2008, you can use SQL Server 2005, but you will need to download the 2005 AdventureWorks samples.

The goal of this article is to create a web page that looks like the following image. 

Figure 1

The user can change the group in the report by either using a database field or a formula field.  The Tables and Fields drop down list are populated with the tables and fields that are defined in the Crystal Report file. Clicking the "Preview With DB Fields" button will change the group in the report to use the field selected in the drop down list. The Formula Fields drop down list is populated with all the formulas in the report. This particular report has formula fields for the Year, Quarter, Month, and Week for each employee's date of hire. The "Preview With Formula Fields" button changes the group in the report to the selected item in the Formula Fields drop down list.  The report is displayed in the web page by using the Crystal Report Viewer control.


View Entire Article

User Comments

Title: CRystal REports Dynamically   
Name: Naresh
Date: 2012-12-07 11:48:18 PM
Comment:
Good
Title: t   
Name: n
Date: 2012-12-07 11:47:21 PM
Comment:
ertt
Title: Another nice article   
Name: Rick
Date: 2009-12-01 4:02:34 PM
Comment:
Easy to follow and godd explainations. Thanks for taking the time to put this article together. I have gone through the other 3 parts and really getting a better feel fot the reports
Title: ASP.NET Crystal Reports Hosting   
Name: Helen
Date: 2009-10-13 8:46:44 PM
Comment:
I real like this article and I could learn more things about Crystal Reports
Thanks

___________________________________________________
http://www.webhost4lifereview.com/crystal-report-web-hosting/
Title: Can anybody help me please?   
Name: Beto
Date: 2009-10-02 12:40:03 PM
Comment:
What's up? I hope you help me... I want to have a report that has 3 pages per sheet... How can I do that? Thanks beforehand =)
Title: Very Nice Artical   
Name: Gaurav Gupta
Date: 2009-09-24 5:13:31 AM
Comment:
Dear Vince Varallo

The article is really great.It is very useful to understand crystal report. And the way of communicating is also very simple.

Thanks
Gaurav Gupta
Title: Problem   
Name: Pankaj Rai
Date: 2009-09-18 2:16:54 AM
Comment:
Dear Vince Varallo,

I have to made a crystal report which show the sum of amount datewise. And also to display all the transaction on particular date when I click on date feild in crystal report.Is there any technique to pass date as parameter for subreport.Please reply ASAP.


Thanks in Advance.
Title: Really Nice Artical   
Name: Pankaj Rai
Date: 2009-09-18 2:13:10 AM
Comment:
I have read this and learn something good regarding crystal report.

Thanks
Title: Very Good   
Name: Edwin
Date: 2009-09-10 10:56:39 AM
Comment:
I have been reading all the 4 parts and its very very usefull. Thanks a million. Just on more wish !!

VB code along with C# would have been amazing. Does your book has VB code as well as C#?

Product Spotlight
Product Spotlight 



Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2017 ASPAlliance.com  |  Page Processed at 2017-09-24 3:21:58 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search