Click here to Skip to main content
15,896,606 members
Articles / Containers / Virtual Machine

ASP.NET Report Kit Grasshoper (Race to Linux)

Rate me:
Please Sign up or sign in to vote.
2.38/5 (5 votes)
2 Oct 20057 min read 38K   19  
Porting and deploying the report starter kit to Linux (RH7.3/Tomcat5.0.28/Grasshoper1.61)
<html><head><link rel=stylesheet href=style.css></head><body><div class=SourcePanel style='font-size:12'><pre style='background-color:white'>
<font color= "blue">Imports</font> System
<font color= "blue">Imports</font> System.Web.UI.WebControls
<font color= "blue">Imports</font> ASPNET.StarterKit.Reports.Components
<font color= "blue"></font>
<font color= "blue">Namespace</font> ASPNET.StarterKit.Reports
<font color= "blue"></font>
<font color= "green">    '*********************************************************************</font>
<font color= "green">    '</font>
<font color= "green">    ' DrillDown.aspx</font>
<font color= "green">    '</font>
<font color= "green">    ' The drilldown report displays customer order info. Users are presented with </font>
<font color= "green">    ' a list of customers. From there, they can focus in on a customer and see the</font>
<font color= "green">    ' orders shipped to that customer. Then, they can focus in on an order ID to </font>
<font color= "green">    ' view the details for a particular order.</font>
<font color= "green">    '</font>
<font color= "green">    '*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">    Public Class</font> DrillDown
<font color= "blue">        Inherits</font> System.Web.UI.Page
<font color= "blue">        Protected </font>CustomerList <font color= "blue">As </font>System.Web.UI.WebControls.DataList
<font color= "blue">        Protected </font>PrintButton <font color= "blue">As </font>System.Web.UI.WebControls.HyperLink
<font color= "blue">        Protected </font>_styleSheet <font color= "blue">As </font>String
<font color= "blue"></font>
<font color= "blue">        Private </font>_customerID <font color= "blue">As </font>String = "CustomerID"
<font color= "blue"></font>
<font color= "blue"></font>#Region " Web Form Designer Generated Code "
<font color= "blue"></font>
<font color= "green">        'This call is required by the Web Form Designer.</font>
<font color= "blue">        </font><System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
<font color= "blue"></font>
<font color= "blue">        End Sub</font>
<font color= "blue"></font>
<font color= "blue">        Private Sub</font> Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
<font color= "green">            'CODEGEN: This method call is required by the Web Form Designer</font>
<font color= "green">            'Do not modify it using the code editor.</font>
<font color= "blue">            </font>InitializeComponent()
<font color= "blue">        End Sub</font>
<font color= "blue"></font>
<font color= "blue"></font>#End Region
<font color= "blue"></font>
<font color= "blue">        Private Sub</font> Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
<font color= "blue"></font><font color= "blue">            If </font>Not IsPostBack <font color= "blue">Then</font>
<font color= "blue">                </font>BindList()
<font color= "blue"></font><font color= "blue">            End If</font><font color= "blue"></font>
<font color= "blue"></font>
<font color= "green">            ' switches the style sheet based on printer friendly view or not</font>
<font color= "blue"></font><font color= "blue">            If </font>Request.QueryString("Print") = "true" <font color= "blue">Then</font>
<font color= "blue">                </font>_styleSheet <font color= "blue"></font>= "stylesPrint.css"
<font color= "blue">                </font>PrintButton.Visible = True
<font color= "blue"></font><font color= "blue">            Else</font><font color= "blue"></font>
<font color= "blue">                </font>_styleSheet <font color= "blue"></font>= "styles.css"
<font color= "blue"></font><font color= "blue">            End If</font><font color= "blue"></font>
<font color= "blue">        End Sub</font><font color= "green"> 'Page_Load</font>
<font color= "blue"></font>
<font color= "green">        '*********************************************************************</font>
<font color= "green">        '</font>
<font color= "green">        ' The BindList method retrieves the list of customers</font>
<font color= "green">        ' and then databinds them to the Customers Datalist</font>
<font color= "green">        '</font>
<font color= "green">        '*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">        Private Sub</font> BindList()
<font color= "blue">            </font>CustomerList.DataSource = DrillDownReport.GetCustomers()
<font color= "blue">            </font>CustomerList.DataBind()
<font color= "blue">        End Sub</font><font color= "green"> 'BindList</font>
<font color= "blue"></font>
<font color= "green">        '*******************************************************</font>
<font color= "green">        '</font>
<font color= "green">        ' DataList_ItemCommand event handler is tied to the OnItemDataBound of the Customers DataList.</font>
<font color= "green">        ' It sets the selected index of the Customers List and then re-binds.</font>
<font color= "green">        '</font>
<font color= "green">        '*******************************************************</font>
<font color= "blue"></font>
<font color= "blue">        Protected Sub</font> CustomersList_ItemCommand(ByVal Sender As Object, ByVal e As DataListCommandEventArgs)
<font color= "green">            ' change the Datalist to selected index</font>
<font color= "blue">            Dim </font>cmd <font color= "blue">As </font>String = CType(e.CommandSource, LinkButton).CommandName
<font color= "blue"></font><font color= "blue">            If </font>cmd = "select" <font color= "blue">Then</font>
<font color= "blue">                </font>CType(Sender, DataList).SelectedIndex = e.Item.ItemIndex
<font color= "blue"></font><font color= "blue">            End If</font><font color= "blue"></font>
<font color= "green">            ' re-bind to display data with the new selected index</font>
<font color= "blue">            </font>BindList()
<font color= "blue"></font>
<font color= "green">            ' store the customer id to re-bind in the orders list</font>
<font color= "blue">            </font>ViewState(_customerID) = CType(e.Item.FindControl("CustomerID"), Label).Text
<font color= "blue">        End Sub</font><font color= "green"> 'CustomersList_ItemCommand</font>
<font color= "blue"></font>
<font color= "green">        '*******************************************************</font>
<font color= "green">        '</font>
<font color= "green">        ' OrdersList_ItemCommand event handler is tied to the OnItemDataBound of the Orders DataList.</font>
<font color= "green">        ' It sets the selected index of the Orders List and then re-binds.</font>
<font color= "green">        '</font>
<font color= "green">        '*******************************************************</font>
<font color= "blue"></font>
<font color= "blue">        Protected Sub</font> OrdersList_ItemCommand(ByVal Sender As Object, ByVal e As DataListCommandEventArgs)
<font color= "green">            ' change the selected index of Orders Datalist</font>
<font color= "blue">            Dim </font>cmd <font color= "blue">As </font>String = CType(e.CommandSource, LinkButton).CommandName
<font color= "blue">            Dim </font>senderlist <font color= "blue">As </font>DataList = CType(Sender, DataList)
<font color= "blue"></font><font color= "blue">            If </font>cmd = "select" <font color= "blue">Then</font>
<font color= "blue">                </font>senderlist.SelectedIndex = e.Item.ItemIndex
<font color= "blue"></font><font color= "blue">            End If</font><font color= "blue"></font>
<font color= "green">            ' re-bind to display orders info with new selected index.</font>
<font color= "blue">            </font>senderlist.DataSource = GetOrders(CStr(ViewState(_customerID)))
<font color= "blue">            </font>senderlist.DataBind()
<font color= "blue">        End Sub</font><font color= "green"> 'OrdersList_ItemCommand</font>
<font color= "blue"></font>
<font color= "green">        '*********************************************************************</font>
<font color= "green">        '</font>
<font color= "green">        ' The GetOrders method calls the BLL to retrieve the list of orders shipped</font>
<font color= "green">        ' for customer with customerID.</font>
<font color= "green">        '</font>
<font color= "green">        '*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">        Protected Function</font> GetOrders(ByVal customerId As String) As DrillDownReportCollection
<font color= "green">            ' only use the customerID in session if it doesn't exist.</font>
<font color= "blue"></font><font color= "blue">            If </font>customerId Is Nothing <font color= "blue">Then</font>
<font color= "blue">                </font>customerId <font color= "blue"></font>= CStr(ViewState(_customerID))
<font color= "blue"></font><font color= "blue">            End If</font><font color= "blue"></font>
<font color= "blue">            </font>Return <font color= "blue"></font>DrillDownReport.GetOrders(customerId)
<font color= "blue"></font><font color= "blue">        End Function   </font><font color= "blue"></font><font color= "green"> 'GetOrders</font>
<font color= "blue"></font>
<font color= "green">        '*********************************************************************</font>
<font color= "green">        '</font>
<font color= "green">        ' The GetOrderDetails method calls the BLL to retrieve order info given an order id.</font>
<font color= "green">        '</font>
<font color= "green">        '*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">        Protected Function</font> GetOrderDetails(ByVal orderID As Integer) As DrillDownReportCollection
<font color= "blue">            </font>Return <font color= "blue"></font>DrillDownReport.GetOrderDetails(orderID)
<font color= "blue"></font><font color= "blue">        End Function   </font><font color= "blue"></font><font color= "green"> 'GetOrderDetails</font>
<font color= "blue"></font><font color= "blue">    End Class</font><font color= "blue"></font><font color= "green"> 'DrillDown</font>
<font color= "blue"></font><font color= "blue">End Namespace</font><font color= "blue"></font><font color= "green"> 'ASPNET.StarterKit.Reports</font>
</pre>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
I love to code! Working in C# is my passion, visit my github

Comments and Discussions