Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Partial Class Default8
Inherits System.Web.UI.Page
' Private conStr As String ' = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=" & Server.MapPath("db1.mdb")
Private conStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db1.mdb") & ";"
'Private conStr As String = "Server=(local);database=reservation_system;uid=rssadmin;password=PAma22"
Protected WithEvents droBuild1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents droFloor1 As System.Web.UI.WebControls.DropDownList
Private Shared dsChild As New DataSet
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
'Put user code to initialize the page here
If IsPostBack = False Then BindDropDownList()
Dim objConn As OleDbConnection
Dim strconnString As String = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=" & Server.MapPath("db1.mdb")
objConn = New OleDbConnection(strconnString)
objConn.Open()
Dim mycommand As New OleDbCommand("Select * From province", objConn)
GridView1.DataSource = mycommand.ExecuteReader
GridView1.DataBind()
objConn.Close()
End Sub
Private Sub BindDropDownList()
Dim conn As New OleDbConnection(conStr)
conn.Open()
Dim ds As New DataSet
Dim da As New OleDbDataAdapter("Select * From province", conn)
da.Fill(ds, "province")
DropDownList1.DataSource = ds.Tables("province")
DropDownList1.DataTextField = ("PROVINCE_NAME")
DropDownList1.DataValueField = ("PROVINCE_ID") ' binding
DropDownList1.DataBind()
da.Dispose()
conn.Dispose()
DropDownListChild()
End Sub
Private Sub DropDownListChild()
Dim conn As New OleDbConnection(conStr)
conn.Open()
Dim da As New OleDbDataAdapter("SELECT * FROM some1 WHERE PROVINCE_ID ='" & DropDownList1.SelectedItem.Value & "'", conn)
dsChild = New DataSet
da.Fill(dsChild, "some1")
DropDownList2.DataSource = dsChild.Tables("some1")
DropDownList2.DataTextField = ("Route")
DropDownList2.DataValueField = ("PROVINCE_ID")
DropDownList2.DataBind()
da.Dispose()
conn.Dispose()
'DisplayImage()
End Sub
'Private Sub DisplayImage()
' sSel As String = "FLOOR = " & droFloor.SelectedValue
' If dsChild.Tables.Count > 0 Then
'Dim dr() As DataRow = dsChild.Tables(0).Select(sSel)
' Dim Path As String = dr(0)("MAP_PATH")
' Response.Write(Path)
'End If
' End Sub
Private Sub DropDownList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim ctrlId As String = CType(sender, DropDownList).ID.ToLower()
Select Case ctrlId
Case "Dropdownlist1"
'DropDownList2.DataBind()
DropDownListChild()
Case "Dropdownlist2"
'DisplayImage()
' droFloor.Enabled = True
Case Else
End Select
End Sub
End Class