Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
ImProvince()
End Sub
Sub ImProvince()
If IsPostBack = False Then
dtAdapter = New SqlDataAdapter("select * from Add_Provinces ORDER BY PROVINCE_NAME", objConn)
dtAdapter.Fill(ds, "Add_Provinces")
DDLProvinces.DataSource = ds.Tables("Add_Provinces")
DDLProvinces.DataTextField = "PROVINCE_NAME"
DDLProvinces.DataValueField = "PROVINCE_ID"
DataBind()
DDLAmphur.Items.Clear()
ds = New DataSet
dtAdapter = New SqlDataAdapter("select * from Add_Amphur where PROVINCE_ID='" & DDLProvinces.SelectedValue.ToString & "' ", objConn)
dtAdapter.Fill(ds, "Add_Amphur")
For i = 0 To ds.Tables(0).Rows.Count() - 1
DDLAmphur.DataSource = ds.Tables("Add_Amphur")
DDLAmphur.DataTextField = "AMPHUR_NAME"
DDLAmphur.DataValueField = "AMPHUR_ID"
DataBind()
Next
objConn.Close()
End If
End Sub
Protected Sub DDLProvinces_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DDLProvinces.SelectedIndexChanged
If objConn.State = ConnectionState.Closed Then
objConn.Open()
End If
DDLAmphur.Items.Clear()
ds.Clear()
dtAdapter = New SqlDataAdapter("SELECT * from Add_Amphur where PROVINCE_ID='" & DDLProvinces.SelectedValue.ToString & "' ", objConn)
dtAdapter.Fill(ds, "Add_Amphur")
For i = 0 To ds.Tables(0).Rows.Count() - 1
DDLAmphur.DataSource = ds.Tables("Add_Amphur")
DDLAmphur.DataTextField = "AMPHUR_NAME"
DDLAmphur.DataValueField = "AMPHUR_ID"
DataBind()
Next
objConn.Close()
End Sub
Sub ImProvince()
dtAdapter = New SqlDataAdapter("select * from Add_Provinces ORDER BY PROVINCE_NAME", objConn)
dtAdapter.Fill(ds, "Add_Provinces")
DDLProvinces.DataSource = ds.Tables("Add_Provinces")
DDLProvinces.DataTextField = "PROVINCE_NAME"
DDLProvinces.DataValueField = "PROVINCE_ID"
DataBind()
End Sub
Sub ImAmphur()
If DDLProvinces.AutoPostBack = True Then
dtAdapter = New SqlDataAdapter("select AMPHUR_NAME,AMPHUR_ID from Add_Amphur where PROVINCE_ID='" & DDLProvinces.SelectedValue & "' ", objConn)
dtAdapter.Fill(ds, "Add_Amphur")
For i = 0 To ds.Tables(0).Rows.Count() - 1
DDLAmphur.DataSource = ds.Tables("Add_Amphur")
DDLAmphur.DataTextField = "AMPHUR_NAME"
DDLAmphur.DataValueField = "AMPHUR_ID"
DataBind()
Next
End If
End Sub
Protected Sub DDLProvinces_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DDLProvinces.SelectedIndexChanged
ImAmphur()
End Sub