ASP.NET - ReportViewer & Report

In the new ASP.NET 2.0, there is a control called ReportViewer, which could be used to display a report. It provides a lot of in-built functionality that could ease website development, such as sorting, page navigating, printing, and even exporting it into Excel.

As mentioned above, ReportViewer is used to display a report. It acts as a container to display a report with RDLC extension (.rdlc), much like a web brower is used to display web page in HTML format. One container can be used to display report file, but it cannot used to display more than 1 report at the same time, unless it's a nested report (report within a report). RDLC is basically a template, where we could drag and drop the desired controls to create our own report. The underlying language is actually XML.

The process to develop a ReportViewer is quite straight forward, but it can be very complicated at time as well do deal with. In Visual Studio 2005, the ReportViewer control is placed under the section Data on the left tool pane, which hints that it ties with database, and it is. The process involved are:

1. Create a data source mapping object (.xsd)
This data source mapping object contains information that would map to either a SQL query, or a pre-defined stored procedure. A data source mapping object can contains many mapping, wich each mapping stored in a Table Adapter.

2. Create a report file (.rdlc)
The report file is added in Visual Studio 2005 through Add New Item. In the template, all we need to do is to drag the necessary objects and place it into the template. There are several objects being provided, such as text box, table, and matrix. The objects that could be edited are used to hold information retrieved from the database through the data source mapping object that I mentioned above. All we need to, i.e. drag a table onto the report template, select the necessary field from the data source mapping pane on the left (shared with tools), and drag it into the table. That's it.

3. Place a ReportViewer onto the web page
As mentioned, go to the webpage/web form, drag the control into the webpage, and then configure it to point to a report file. After the configuration, please do notice that there would be several (minimum 1, I think) ObjectDataSource objects added into your webpage. Each object will have to be configured correctly, otherwise the report would not work.

It is indeed a very good features, but it does come with certain things that could cause significant headach as well. Firstly, the ObjectDataSource objects that being added to the webpage, although if the report is updated to not require it anymore, the ReportViewer may still contain the linkage to that source, although the configuration has been updated. When this happened, I will just delete the control and place a new one instead.

Second, the data mapping object does not update itself automatically. Unlike the aspx file that would update itself on runtime, the data mapping object has to be reconfigured either through Visual Studio 2005 or through the edting of the file itself, if you know how to do it.

Thirdly, you may encounter a problem while putting up the website with ReportViewer onto a production web server, where it would say that ReportViewer cannot be recognized although .NET Framework 2.0 has been installed. The reason is simple, ReportViewer doesn't come with .NET Framework 2.0, it is a standalone control that has to be installed separately. The installer can be found within Visual Studio 2005 program files folder.

Forthly, placing data fields from the data mapping source into a container within a report, i.e. table may give you undesirable result: It supposed to display i.e. a list of users' email, but instead it shows an expression that would display total users' email. I have no idea either on how this could happen, and when it does, I will just scrap the whole report file and build a new one from scratch again, which can be very painful if a lot of things have been done.

Fitfhly, although each field within the report can be modified with custom macro functions to display more informative data, a novice people would not understand how to use it, 'coz it's really technical orientated.

Sixthly, although it is very useful and ease development process, but you may scream and yell when the control are all messes up when it is viewed with Firefox 2.0. It will view (not exactly like what we saw in IE) in Firefox 3.0 and above, but it may still not up to expectation, like a text box that should display in 1 line would all of a sudden display in 2 line, and squeezes itself whereas there's a lot of space on the page. It has to deal with the way Firefox handles the XML of the RDLC file, of which I found on the net that it doesn't handle nested <table> tag that well. One way to improve this is to place all the controls inside a square box that acts as a container.

And so the list goes on and on...

Anyway, that's all for now.

Comments

Popular posts from this blog

Yahoo! Messenger voice call & video call disabled, why?

Sport's Injuries - Treatment for bruises

Web Development: Disable, Validate, & Enable Buttons