ASP.NET
  Home arrow ASP.NET arrow Page 3 - 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 
Mobile Linux 
App Generation ROI 
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 - Where does the processing start?


    (Page 3 of 4 )

    The processing starts when you call “LoadData.”  The following is the code I wrote in “LoadData:”

        Public Sub LoadData()
            Dim dtReport As DataTable
            Select Case TypeOfObject
                Case ObjectType.Table
                    dtReport = getCrossTab_LevelSingle_ForTable()
                Case ObjectType.StoredProcedure
                    dtReport = getCrossTab_LevelSingle_ForSP()
            End Select
            Me.DataSource = dtReport
            Me.DataBind()
        End Sub

    It is really very simple.  I just made it very precise for proper readability.  Based on the data source (for retrieving information) provided by the user, the processing starts either at “getCrossTab_LevelSingle_FoTable” (for table) or “getCrossTab_LevelSingle_FoSP” (for stored procedure).

    The following is the complete source code for the cross-tab engine (dealing with the table):

    Private Function getCrossTab_LevelSingle_ForTable() As DataTable
            Dim tblname As String = ObjectName
            Dim SmryType As OperationType = Me.TypeOfOperation
            Dim dtReport As New DataTable
     
            'adding columns to the report data table
            dtReport.Columns.Add("Details")
            Dim dtColumns As DataTable = getDataTable("select distinct " & ColFieldName & " from " & tblname & " order by " & ColFieldName)
            For Each drColumn As DataRow In dtColumns.Rows
                dtReport.Columns.Add(drColumn(0))
            Next
            'additional blank columns
            For i As Integer = 1 To AdditionalBlankColumns
                dtReport.Columns.Add(New DataColumn)
            Next
     
            'adding rows to the report data table
            Dim dtRowField As DataTable = getDataTable("select distinct " & RowFieldName & " from " & tblname & " order by " & RowFieldName)
            For Each drRowField As DataRow In dtRowField.Rows
                Dim drReport As DataRow = dtReport.NewRow
                drReport("details") = drRowField(0)
                For Each drColumn As DataRow In dtColumns.Rows
                    drReport(drcolumn(0)) = getRowValue("select " & [Enum].GetName(GetType(OperationType), SmryType) & "(" & SummaryFieldName & ") from " & tblname & " where " & RowFieldName & "='" & drRowField(0) & "' and " & ColFieldName & "='" & drcolumn(0) & "'")
                Next
                dtReport.Rows.Add(drReport)
            Next
            Return dtReport
        End Function



    The next section gives you the complete source code for the cross-tab engine (dealing with stored procedures).

    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

    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - 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





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