filter combobox in a datgrid based on another combobox vb.net
Hi ,,
i have problem with combobox
i have two combobox and two tables
table manages (ManageID, ManageName)
table Departments (DeptID, DeptName, Dept_ManageID)
1- CboEmp_Manage
2- CboEmp_Dept
Public Class Class1
Public sub FillCombobox (ByVal cbo As Combobox, ByVal TableName As String , ByVal Col_name As String , ByVal Col_Value As String )
Try
Dim VarSql As String
VarSql = ""
VarSql = "Select " + Col_name + " , " + Col_Value + " From " + TableName + " "
Dim sda As New SqlDataAdapter(VarSql , SQLCon)
Dim ds As New Dataset ()
sda.Fill(ds)
cbo.DataSource = ds.Tables(0)
cbo.DisplayMember = Col_name
cbo.ValueMember = Col_Value
Catch
End Try
End Sub
Private Sub CboEmp_Manage_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CboEmp_Manage.SelectedValueChanged
WinClass.FillCombobox (CboEmp_Dept, "Departments WHERE Dept_Manage_ID='" & CboEmp_Manage.SelecteIndex.ToString() & "' " , "Dept_Name", "Dept_ID")
End Sub
its work but its give me wrong data from table