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 APNSoft.WebControls

Partial Public Class DataGrid_RowServerSelection
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        'Apply event-handling method
        AddHandler myDataGrid.OnRowClick, AddressOf myDataGrid_SelectCommand

        'Define SQL query
        Dim SqlQuery As String = "SELECT CustomerID, CompanyName, ContactName, Address, PostalCode " & _
            "FROM Customers ORDER BY CustomerID"

        'Get DataTable (MS Access Database)
        Dim myDataSource As DataTable = DataBase.GetDataTableOleDb(SqlQuery, "~/DataGrid/DataBases/Nwind.mdb")

        'Set the data source
        myDataGrid.KeyFieldName = "CustomerID"
        myDataGrid.DataSource = myDataSource

    End Sub

    'The Server Side Procedure
    Private Sub myDataGrid_SelectCommand(ByVal sender As Object, ByVal e As DataGridEventArgs)
        'Get selected row
        Dim myGridRow As GridRow = e.GridRow
        If myGridRow Is Nothing Then
        End If

        'Reset the lblSelRow
        lblSelRow.Text = ""
        lblSelRow.Text &= "Row index: <b>" & _
            myGridRow.RowIndex & "</b><br/>"

        For i As Integer = 0 To myGridRow.Cells.Count - 1
            lblSelRow.Text += myGridRow.Cells(i).ColumnName & ": <b>" & _
            myGridRow.Cells(i).Value.ToString() & "</b><br/>"
        Next i

        lblSelRow.Text &= "<br/>"

    End Sub

End Class