ผมก้อใช้ selectIndexChanged แต่ว่ามาน error ครับ
ผมใช้แบบ dim TypeId as string = Combobox.selectvalue
Date :
2010-10-17 01:09:31
By :
ibankza11
No. 6
Guest
Code (VB.NET)
Private Sub Customers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If F_Connection(conn) = False Then Exit Sub
Call_province()
call_amphur()
End Sub
Private Sub Call_province()
If F_Connection(conn) = False Then Exit Sub
ds.Tables.Clear()
Try
ls_sql = "SELECT provinceid,des FROM tblprovince "
ls_sql &= "ORDER BY des"
da = New SqlDataAdapter(ls_sql, conn)
da.Fill(ds, "province")
If ds.Tables("province").Rows.Count <> 0 Then
With cb_province
.DataSource = ds.Tables("province")
.DisplayMember = "des"
.ValueMember = "provinceid"
End With
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub call_amphur()
ds.Tables.Clear()
Try
ls_sql = "SELECT amphur_id,des FROM tblamphur "
If cb_province.ValueMember = "" Then
Exit Sub
Else
ls_sql &= "where province_id = '" & CStr(cb_province.SelectedValue) & "'"
ls_sql &= "ORDER BY des"
da = New SqlDataAdapter(ls_sql, conn)
da.Fill(ds, "tblamphur")
If ds.Tables("tblamphur").Rows.Count <> 0 Then
With cb_amphur
.DataSource = ds.Tables("tblamphur")
.DisplayMember = "des"
.ValueMember = "amphur_id"
End With
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub cb_province_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cb_province.SelectedValueChanged
call_amphur()
End Sub