Option Strict Off
Imports System
Imports System.Collections
Imports System.Text
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Class BaseClass
	Inherits System.Web.UI.Page
	protected Grid1 as DataGrid
	Protected Message as label
	Dim myConnection As OleDbConnection
	Dim myCommand    As OleDbDataAdapter
	Dim ds           As New DataSet
	Dim ConnStr      As String
	Dim SQL          As String
	Sub Page_Load(Source As Object, E As EventArgs) 
	   ConnStr = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=ASPNET;User ID=sa;"
	   myConnection = New OleDbConnection(ConnStr)      
	    if NOT (isPostBack)
		rebind
	    end if
	End Sub

	Sub ReBind()
		SQL = "select  m.*, g.code_display as category "
		SQL = SQL + "from masters m,  groups g "
		SQL = SQL + " where m.code_category = g.code_value"
		myCommand = New OleDbDataAdapter(SQL, myConnection)
		'使用DataSetCommand的Fill方法来填充DataSet
		myCommand.Fill(ds, "masters")
		'绑定 DataGrid	
		Grid1.DataSource=ds.Tables("masters").DefaultView
		Grid1.DataBind()
	End Sub
	'-------------- 新事件(加入到Masters1.vb中)---------------------------
	Sub Grid1_Edit(Sender As Object, E As DataGridCommandEventArgs)
		Grid1.EditItemIndex = E.Item.ItemIndex
		ReBind()
	End Sub
	Sub Grid1_Cancel(Sender As Object, E As DataGridCommandEventArgs)
		Grid1.EditItemIndex = -1
		ReBind()
	End Sub
	Sub RunSql(sql as string)
		'在Masters3.vb中要用到的占位符
		response.write(sql)
	End sub
End Class
