Extending an ASP.NET Datagrid to Support Simple Cross Tab Reporting: The Structure
(Page 1 of 4 )
This article guides you through developing your own ASP.NET custom control by extending the existing datagrid control (in ASP.NET). It mainly concentrates on Cross Tab Reporting with the ASP.NET data grid.
A downloadable file for this article is available
here.
If you are very new to developing ASP.NET custom controls, I suggest you refer to my long series titled “ASP.NET custom server controls.” It would definitely help you in working with some fundamental custom controls.
The entire source code is developed using Visual Studio.NET 2003 Enterprise Architect with SQL Server 2000 enterprise edition on Windows Server 2003 standard edition. I didn’t really test the source code in any of the previous releases or later releases apart from the above. Please drop me a line if you really want it customized with any of the later releases along with some suggestions for features or enhancements you want.
I strongly suggest you customize the custom control to suit your needs.
What is inside my custom control?
I was really expecting some new server controls from Microsoft to support cross tab reporting. Instead, Microsoft offers that option only through SQL Server Reporting Services or Crystal Reports. Apart from those two technologies (and third-party vendors), there exists no control to support a cross-tab reporting system.
But I'm still happy with the flexibility that Microsoft offered with datagrid. It really has enormous depth; we just need to use our skill to mold it according to our requirements. Finally, I started with a simple cross tab control (by extending it from datagrid) to support basic cross tabbing. To my surprise, it really worked as I expected. Even though it may not be very useful for enterprise reporting, I can still use it for small cross-tab reports. And there is always a chance for extensibility.
Coming to my custom control, it has a region called “Core Database Routines,” which is very similar to DAL. It is just a small interpretation of the same. The region contains the following methods within it:
- getRowValue
- getDataTable
- SPgetDataTable
- SPaddParameter
Those are the methods I mostly used to work with the custom control. The first two shall work directly with the tables, and the last two work with stored procedures.
Apart from the above, I also developed one more class to handle all parameters (or parameter caches) which are likely to be passed to stored procedures. It is named “MSSQLProcParameter.” Even though it is not necessary, it eased some of my problems.
Not only that, I declared three more enumerations, especially to provide properties. Those are as follows:
- OperationType (could be sum, avg, etc.)
- ObjectType (could be either table or stored procedure)
- MSSQLDataType (my own mapping of data types)
I could not finish without giving several additional properties to the custom control as it is related to the cross tab. The following is the list of properties I managed to declare:
- ObjectName
- TypeOfObject
- RowFieldName
- ColFieldName
- SummaryFieldName
- TypeOfOpeation
- AdditionalBlankColumns
And finally, I managed to get entire thing working with a simple method, named “LoadData.”
That gives you an overall idea of the inner workings of the custom control. Now let us delve into the details.
Next: The enumerations declared in the custom control >>
More ASP.NET Articles
More By Jagadish Chaterjee