ASP.NET
  Home arrow ASP.NET arrow Extending an ASP.NET Datagrid to Support S...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Extending an ASP.NET Datagrid to Support Simple Cross Tab Reporting: The Source Code
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2006-03-06

    Table of Contents:
  • Extending an ASP.NET Datagrid to Support Simple Cross Tab Reporting: The Source Code
  • The core database routines to work with stored procedures: “SPgetDataTable” method
  • Where does the processing start?
  • Cross-tab processing with the information from the stored procedure

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Extending an ASP.NET Datagrid to Support Simple Cross Tab Reporting: The Source Code


    (Page 1 of 4 )

    This article, second in the series, guides you through developing your own ASP.NET custom control by extending the existing datagrid control (in ASP.NET). The main concentration will be on Cross Tab Reporting with ASP.NET data grid.

     This article gives you only the complete source code for the custom control.  You can expect the explanation for the source code in an upcoming article.


    A downloadable file for this article is available here.

    You can find the first article in this series here.

    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 latest releases apart from the above.  Please drop me a line if you really want it customized with any of the latest releases, along with some suggestions for features or enhancements you want.

    I strongly suggest you customize the custom control to suit your needs.

    The core database routines to work with stored procedures: the methods

    I already presented the entire structure of the custom control in my previous article.  Now, in this article, I will focus on the processing engines for the cross-tab.  Before I do that, I need to introduce you to two more methods I used to access stored procedures.  Let us have a look at the complete code for the first one:

    Public Sub SPaddParameter(ByVal ParameterName As String, Optional ByVal Value As Object = Nothing, Optional ByVal SQLType As MSSQLDataType = Nothing, Optional ByVal Size As Integer = Nothing, Optional ByVal Direction As ParameterDirection = ParameterDirection.Input)
            Dim buildDataType As SqlDbType
            Dim buildParameter As MSSQLProcParameter = Nothing
     
            Select Case SQLType
                Case MSSQLDataType.SQLString
                    buildDataType = SqlDbType.VarChar
                Case MSSQLDataType.SQLChar
                    buildDataType = SqlDbType.Char
                Case MSSQLDataType.SQLInteger
                    buildDataType = SqlDbType.Int
                Case MSSQLDataType.SQLBit
                    buildDataType = SqlDbType.Bit
                Case MSSQLDataType.SQLDateTime
                    buildDataType = SqlDbType.DateTime
                Case MSSQLDataType.SQLDecimal
                    buildDataType = SqlDbType.Decimal
                Case MSSQLDataType.SQLMoney
                    buildDataType = SqlDbType.Money
                Case MSSQLDataType.SQLImage
                    buildDataType = SqlDbType.Image
                Case MSSQLDataType.SQLFloat
                    buildDataType = SqlDbType.Float
            End Select
     
            buildParameter = New MSSQLProcParameter(ParameterName, Value, buildDataType, Size, Direction)
     
            Dim dtParameterList As DataTable
            If viewstate("dtParameterList") Is Nothing Then
                dtParameterList = New DataTable
                dtParameterList.Columns.Add(New DataColumn("ParamDetail", GetType(String)))
                viewstate("dtParameterList") = dtParameterList
            End If
     
            Dim dr As DataRow = dtParameterList.NewRow
            'dr("ParamDetail") = buildParameter
            Dim ser As XmlSerializer = New XmlSerializer(GetType(MSSQLProcParameter))
            Dim sb As New StringBuilder
            Dim writer As New StringWriter(sb)
            ser.Serialize(writer, buildParameter)
            writer.Close()
            dr("ParamDetail") = writer.ToString
            dtParameterList.Rows.Add(dr)
     
        End Sub

    Even though the method is bit lengthy, it does nothing other than add a new parameter to the parameter cache.  The parameter cache stays in “dtParameterList” (offline data table).  I use all of the parameters available in “dtParameterList” in “SPgetDataTable” to retrieve information from the stored procedure.

    The next section gives you the complete source code for “SPgetDataTable”.

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · Hello guys, want to know the basics of extending datagrid? Here is a simple article...
     

    ASP.NET ARTICLES

    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ
    - Developing a Dice Game Using ASP.NET Futures...
    - Completing an ASP.NET AJAX Server-Centric Ba...
    - Information Management for an ASP.NET AJAX S...
    - Comment and Order Management for an ASP.NET ...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT