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
Partial Public Class DataGrid_ColumnsTemplateHTML
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
'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
myDataGrid.DataBind()
'Set column properties
myDataGrid.Columns("CustomerID").Width = 530
myDataGrid.Columns("CustomerID").Resizable = False
myDataGrid.Columns("CustomerID").HeaderText = "Customers:"
myDataGrid.Columns("CustomerID").Template = "~/DataGrid/Templates/Customers.html"
myDataGrid.Columns("CompanyName").Visible = False
myDataGrid.Columns("ContactName").Visible = False
myDataGrid.Columns("Address").Visible = False
myDataGrid.Columns("PostalCode").Visible = False
End Sub
End Class
|