|
Imports System
Imports System.Web.UI.WebControls
Imports ASPNET.StarterKit.Reports.Components
Namespace ASPNET.StarterKit.Reports
'*********************************************************************
'
' DrillDown.aspx
'
' The drilldown report displays customer order info. Users are presented with
' a list of customers. From there, they can focus in on a customer and see the
' orders shipped to that customer. Then, they can focus in on an order ID to
' view the details for a particular order.
'
'*********************************************************************
Public Class DrillDown
Inherits System.Web.UI.Page
Protected CustomerList As System.Web.UI.WebControls.DataList
Protected PrintButton As System.Web.UI.WebControls.HyperLink
Protected _styleSheet As String
Private _customerID As String = "CustomerID"
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
BindList()
End If
' switches the style sheet based on printer friendly view or not
If Request.QueryString("Print") = "true" Then
_styleSheet = "stylesPrint.css"
PrintButton.Visible = True
Else
_styleSheet = "styles.css"
End If
End Sub 'Page_Load
'*********************************************************************
'
' The BindList method retrieves the list of customers
' and then databinds them to the Customers Datalist
'
'*********************************************************************
Private Sub BindList()
CustomerList.DataSource = DrillDownReport.GetCustomers()
CustomerList.DataBind()
End Sub 'BindList
'*******************************************************
'
' DataList_ItemCommand event handler is tied to the OnItemDataBound of the Customers DataList.
' It sets the selected index of the Customers List and then re-binds.
'
'*******************************************************
Protected Sub CustomersList_ItemCommand(ByVal Sender As Object, ByVal e As DataListCommandEventArgs)
' change the Datalist to selected index
Dim cmd As String = CType(e.CommandSource, LinkButton).CommandName
If cmd = "select" Then
CType(Sender, DataList).SelectedIndex = e.Item.ItemIndex
End If
' re-bind to display data with the new selected index
BindList()
' store the customer id to re-bind in the orders list
ViewState(_customerID) = CType(e.Item.FindControl("CustomerID"), Label).Text
End Sub 'CustomersList_ItemCommand
'*******************************************************
'
' OrdersList_ItemCommand event handler is tied to the OnItemDataBound of the Orders DataList.
' It sets the selected index of the Orders List and then re-binds.
'
'*******************************************************
Protected Sub OrdersList_ItemCommand(ByVal Sender As Object, ByVal e As DataListCommandEventArgs)
' change the selected index of Orders Datalist
Dim cmd As String = CType(e.CommandSource, LinkButton).CommandName
Dim senderlist As DataList = CType(Sender, DataList)
If cmd = "select" Then
senderlist.SelectedIndex = e.Item.ItemIndex
End If
' re-bind to display orders info with new selected index.
senderlist.DataSource = GetOrders(CStr(ViewState(_customerID)))
senderlist.DataBind()
End Sub 'OrdersList_ItemCommand
'*********************************************************************
'
' The GetOrders method calls the BLL to retrieve the list of orders shipped
' for customer with customerID.
'
'*********************************************************************
Protected Function GetOrders(ByVal customerId As String) As DrillDownReportCollection
' only use the customerID in session if it doesn't exist.
If customerId Is Nothing Then
customerId = CStr(ViewState(_customerID))
End If
Return DrillDownReport.GetOrders(customerId)
End Function 'GetOrders
'*********************************************************************
'
' The GetOrderDetails method calls the BLL to retrieve order info given an order id.
'
'*********************************************************************
Protected Function GetOrderDetails(ByVal orderID As Integer) As DrillDownReportCollection
Return DrillDownReport.GetOrderDetails(orderID)
End Function 'GetOrderDetails
End Class 'DrillDown
End Namespace 'ASPNET.StarterKit.Reports
|
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.
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