Click here to Skip to main content
15,444,203 members
Articles / Web Development / HTML
Tip/Trick
Posted 1 May 2014

Stats

211.4K views
24 bookmarked

RDLC Report Grouping with Page Break, Table Header Repeat, Group Totals and Sub Grouping

Rate me:
Please Sign up or sign in to vote.
4.86/5 (24 votes)
2 May 2014CPOL7 min read
RDLC Report Grouping with Page Break for each Group Type, Table Header repeat for each page and Report Totals

Introduction

Grouping is a critical aspect when it comes to detailed reports or complex report generating. There are many importance that a report has grouping. In this article we are going look some great things with report grouping.

Background

Well this article doesn't have any advance stuff, I am going step by step in creating report and on. But for some this might not suit enough to learn very basic. But I think this is good enough. Let’s see,

Creating The Report

Database table structure which use for demo;

Image 1

Open Visual Studio, here I am using Visual Studio 2012. Create an empty web application. If you want the report in Windows Application go on by creating Windows Application.

Adding DataSet

Once you get your project ready, let’s create the DataSet. DataSet provide disconnected representation of a result from an original database.

So right click on Project -> Add New Item

From the new window opened, select Data Tab from left side panel. Then Select DataSet.

Image 2

After that right click on the data set designer and select Add -> TableAdapter.

Image 3

Then TableAdapter Configuration Wizard window will open.

If you are creating reports in a new project which doesn't have any data base connection strings on web.config you need to create a new connection.

For that click New Connection Button,

Image 4

Then Add Connection window will open.

Enter your server name. If you are using local machine it will be your Machine Name. But if it is a remote server you need to put server name. Any how you couldn't find server name you only need to right click on server in Ms Sql Server -> Properties. Then you find the server name as Name.

Image 5

Once you enter Server Name your databases will populate in to drop down in Connect To a Database Group. Then Select your database.

Image 6

Then Click OK.

From the next screen Tick "Yes, Save the connection as:" so you don't have to set it again. This will save your Connection in Application Configuration file.

Image 7

Then Click Next,

But if you already have your connection, just select the connection and click Next.

Image 8

From the next screen you need to Choose your command type. Whether you are going to get data from a Sql Query or to create a Stored Procedure or Choose a already created stored procedure in database. I have already created my stored procedure in my data base. So I am going to select "Use existing stored procedure"

Image 9

Then Click Next, from next screen select your stored procedure and click Finish.

Image 10

Now you can see you TableAdapter in DataSet Designer.

Image 11

If you need to preview data in Data Set.

Right Click on Table Adapter and select Preview. If your Stored Procedure needs parameters to pass you need to pass them. But in my case it doesn't take any parameters. Click Preview.

Image 12

If you are using a stored procedure with parameters the approach might be different. Since this article is regarding Report Grouping I won't go in to that complex.

Adding Report Viewer

Your dataset is ready to use. Now let’s see how to create the report.

For that you need to create a new WebForm and insert a ReportViewer on to page.

Image 13

Then you need to insert the Ajax Script Manager to page. ReportViewer needs script manager in order to make server calls. Drag and drop Ajax Script Manager from tool box.

Image 14

Now in Page Html Source page or designer page select more option icon on report viewer..

If in Source Page click report viewer tag,

Image 15

If in Designer Page click report viewer.

Image 16

From that select "Design a New Report"

Then Report Wizard will open.

In Report Wizard select created dataset (DataSet1) and Table Adapter. Then click Next.

Image 17

Then from next screen select all the Fields in 'Available Fields' box and drag and drop them to 'Values' box. Choose the fields that you need to be in the report only. Then click Next.

Image 18

From the next screen select the report style. I prefer Ocean.

Image 19

Now your report looks like this.

Image 20

Align your report and make it looks nice and cool.

Now let’s set the report to ReportViewer. For that select more option in report viewer and select choose a report.

Image 21

Image 22

Adding Report Header that Repeats in every page

Now let’s create the Reports header that needs to be display in every page.

Right Click on Report body -> Insert -> Page Header.

Image 23

Insert a report heading and any details that you need to display in report header. You can use report tools panel in left hand side.

Then let’s set the report properties that makes report display in every page.

For that Right Click on report header -> Header Properties.

Image 24

In general tab tick the options as follows.

Image 25

Report Grouping

Following data returns from my Stored Procedure and binds them to my report.

Image 26

I need to Group my data from Product Type and Warehouse.

Let’s start the Report Grouping.

Right Click on the report details row and select Add Group -> Parent Group. Give any relevant name to the group.

Image 27

Now at the bottom of the page you see Row Groups. And it has Group1 and Details.

Right Click on Group1 and select Group Properties.

Image 28

From the Group Properties window select General Tab. Then select the field that needs to be group from Group on. In my case I select "Product Type"

Image 29

Then select Page Breaks tab in the same window.

Check the "Between each instance of Group" and click OK.

Image 30

Now you can see a new column has added to the Table.

In newly added columns select the cell. Now you can see a small icon at the top right in the cell. Click it and select the field that need to be group (in my case it’s Product Type).

Image 31

Image 32

Run the project.

Now you can see that report has break in to several pages group type wise.

Here is mine. You can see the pages of the report in report viewer control panel.

Image 33

Repeating Table Header in every page

Now we need to repeat the Table header as well.

For that you need to click the Arrow in right bottom of the editor and Click Advance Mode.

Image 34

Now you can see two more Grey rows as Static in Row Groups.

Image 35

Click on the Top Static Row and Navigate to Property panel.

Change the "KeepWithGroup" property to 'After' and "RepeatOnNewPage" property to 'True'

Image 36

Image 37

Run the application.

You must see that Table header also have repeated.

Image 38

Report Sub -Grouping

Now we are going to have another child group that group warehouse wise.

For that Right Click on the Group1 -> Add Group -> Child Group

Image 39

Give a relative name to group and add it.

Now as like earlier select the icon on newly added columns cell and select field that need to group. In my case it's Warehouse.

Image 40

Report Sub -Grouping

Now go to child group properties and change the "Group On".

Image 41

Image 42

Run the application and see.

Image 43

Report Totals Row

Now let’s add a Total of Qty column group wise. In my case I need the Product wise total.

For that Right Click on the Child Group cell -> select Add Total -> After.

Image 44

Now you can see that new Row added to table. Deleted non relevant cells.

Image 45

It’s the same to get the Total Product Sum which needs to come on last page. Right Click on the Parent Group cell -> Add Total -> After.

Image 46

You can do the Report Styling as you prefer from the tool bar at the report designer top.

Final Out Come

Now let’s see the Final Report.

Image 47

Page HTML source code.

HTML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="BlogReport.Index" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div>
            <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="1100px">
                <LocalReport ReportPath="Report2.rdlc">
                    <DataSources>
                        <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
                    </DataSources>
                </LocalReport>
            </rsweb:ReportViewer>
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData" TypeName="BlogReport.DataSet1TableAdapters.ProductTransactionsTableAdapter"></asp:ObjectDataSource>
        </div>
    </form>
</body>
</html>

Points of Interest

Google Search results of creating RDLC reports.

https://www.google.lk/search?q=how+to+create+rdlc+reports+in+asp.net&oq=How+to+cre&aqs=chrome.0.69i59j69i57j69i60l2j0l2.6655j0j7&sourceid=chrome&es_sm=122&ie=UTF-8

What is RDLC report?

  • RDLC is a client side reporting, Reports are deployed with the applications (windows app or web app).
  • Limited functionality in exporting the report.
  • Report's data processing and rendering needs space of the hosting application where Reports are hosted.
  • Has performance issue since the report data in process at the report.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Business Analyst
Sri Lanka Sri Lanka
I am a dedicated and innovative software developer that likes to research in Business and its Strategies.
Understanding Business, its Strategies and its Management is my own passion of career, but I add those to my career knowledge and experience in a different taste which is Information Technology and Computer Science. I am employed in IT field. Being in Software Development Industry added more knowledge in IT and its concepts and how to convert those technologies to business world and how to use those in effective and profitable manner.

I am Certified in;
Microsoft Specialist - Programming in HTML5 with JavaScript and CSS3

Comments and Discussions

 
PraiseThanks Pin
aebordones10-Feb-22 11:23
Memberaebordones10-Feb-22 11:23 
GeneralMy vote of 5 Pin
Member 104766133-Oct-20 3:04
MemberMember 104766133-Oct-20 3:04 
PraiseThank you very much Pin
XiaoQing Li29-Nov-17 20:27
MemberXiaoQing Li29-Nov-17 20:27 
QuestionHow to bind Value to Textbox which is outside the Table. Pin
Prasaddwd27-Jul-17 19:01
MemberPrasaddwd27-Jul-17 19:01 
PraiseExceptional Detailed Tutorial Pin
Hifni Shahzard8-May-17 19:58
MemberHifni Shahzard8-May-17 19:58 
GeneralRe: Exceptional Detailed Tutorial Pin
Pavith Goonathilake3-Sep-17 23:33
professionalPavith Goonathilake3-Sep-17 23:33 
Questioncolumn size issue Pin
Member 1178145516-Sep-16 20:41
MemberMember 1178145516-Sep-16 20:41 
AnswerRe: column size issue Pin
Pavith Goonathilake3-Sep-17 23:34
professionalPavith Goonathilake3-Sep-17 23:34 
PraiseThank You Pin
prince_yasser25-Jul-16 3:21
Memberprince_yasser25-Jul-16 3:21 
QuestionHow to display customer address in every page? Pin
Maideen Abdul Kader6-Feb-16 17:32
MemberMaideen Abdul Kader6-Feb-16 17:32 
AnswerRe: How to display customer address in every page? Pin
Pavith Goonathilake3-Sep-17 23:37
professionalPavith Goonathilake3-Sep-17 23:37 
QuestionReally a nice and useful article Pin
ManojSridhar9130-Dec-15 0:49
MemberManojSridhar9130-Dec-15 0:49 
QuestionSQL Table? Pin
flichata28-Dec-15 6:17
Memberflichata28-Dec-15 6:17 
QuestionVERY good article, however... Pin
Member 118914806-Aug-15 9:25
MemberMember 118914806-Aug-15 9:25 
SuggestionMuch Helpful Article but Improve By Follwoing Points Pin
prasunjeet9-Mar-15 0:17
Memberprasunjeet9-Mar-15 0:17 
QuestionThank you Pin
mosababdo26-Feb-15 10:22
Membermosababdo26-Feb-15 10:22 
AnswerRe: Thank you Pin
Pavith Goonathilake18-Mar-15 8:14
professionalPavith Goonathilake18-Mar-15 8:14 
QuestionVery Good Pin
Member 109357201-Aug-14 5:42
MemberMember 109357201-Aug-14 5:42 
GeneralThanks for sharing Pin
Raju_B15-May-14 8:17
MemberRaju_B15-May-14 8:17 
GeneralRe: Thanks for sharing Pin
Pavith Goonathilake18-May-14 20:37
professionalPavith Goonathilake18-May-14 20:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.