user1012598
user1012598

Reputation: 427

Creating a report with a dynamic number of columns

I am developing an ASP.Net c# 4.0 application and am working towards a cross-tab report which will return a dynamically changing number of columns, like so:

Sales Region| ProductA|ProductB|ProductC|........


NorthEast| 10,000 | 3,000 |2,000 |........


SouthEast| 3,000 | 6,000 |2,500 |........ ................................................... ................................................... TOTAL | 100,000| 32,500 |7,800 |........

There is a non determined number of products and regions, so the table returned will have a variable number of columns and rows.

How can I design such a report in Visual Studio 2010, RDLC designer? I have already designed my stored procedure returning the results, but designing the table adapter to return the results gives me no columns (as they are not known).

Upvotes: 1

Views: 5518

Answers (2)

DarkRob
DarkRob

Reputation: 3833

Checkout this link http://www.gotreportviewer.com/matrices/

You can use matrix for your solution. Since you need total with each column so you don't need to sum each column individually. It will create rows and columns dynamically as per the datatable records.

Upvotes: 0

Adrian Iftode
Adrian Iftode

Reputation: 15663

I think you need a "matrix" report.

This tutorial might help you.

Unfortunately you probably need to rewrite the query (I believe you already used PIVOT to obtain the current query).

Upvotes: 1

Related Questions