Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Text

Partial Public Class DataGrid_Templates_Orders
    Inherits System.Web.UI.UserControl
    Public GridRow As APNSoft.WebControls.GridRow = Nothing
    Private SessName As String = "dcvcsey5et23eb"

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        If GridRow Is Nothing Then
        End If

        lblCustomerID.Text = GridRow.Cells("CustomerID").Value.ToString()
        lblCompanyName.Text = GridRow.Cells("CompanyName").Value.ToString()
        lblContactName.Text = GridRow.Cells("ContactName").Value.ToString()

        'Create DataTable object
        Dim myDataTable As DataTable = Nothing
        Dim sessDataTable As DataTable = Nothing

        'Check the DataTable in session
        If Session(SessName) Is Nothing Then
            'Create new DataTable
            Dim SqlQuery As String = "SELECT Customers.CustomerID, Orders.OrderID AS OrderID, " & _
            "Format(Orders.ShippedDate, 'mmm d yyyy') AS ShippedDate, " & _
            "Orders.Freight AS Freight FROM Customers INNER JOIN Orders ON " & _
            "Customers.CustomerID = Orders.CustomerID ORDER BY Orders.OrderID ASC;"

            sessDataTable = DataBase.GetDataTableOleDb(SqlQuery, "~/DataGrid/DataBases/Nwind.mdb")

            Session(SessName) = sessDataTable.Copy()
            myDataTable = sessDataTable
            sessDataTable = CType(Session(SessName), DataTable)
            myDataTable = sessDataTable.Copy()
        End If

        'Set filter
        myDataTable.DefaultView.RowFilter = "CustomerID='" & _
            GridRow.RowID & "'"

        Dim Orders As New StringBuilder()

        'Walk through rows
        For i As Integer = 0 To myDataTable.DefaultView.Count - 1
            Orders.Append(", ")
            Orders.Append(", ")
            Orders.Append("$" & _
        Next i

        'Check for empty collection
        If Orders.Length = 0 Then
            Orders.Append("&nbsp;<font color=red>No orders.</font><br/>")
        End If

        'Add Orders
        phOrders.Controls.Add(New LiteralControl(Orders.ToString()))
    End Sub

End Class