Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27514

Problem with selectionchangecommited of combobox

$
0
0
Private Sub cmbGroupName_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbGroupName.SelectionChangeCommitted
MessageBox.Show(cmbGroupName.Text)

Dim da As New SqlDataAdapter()
Dim ds As New DataSet()
Try
da = New SqlDataAdapter("select item_id,item_name from items where group_name like '" + cmbGroupName.Text + "' and status like 'Active'", cl.sqlConn())
da.Fill(ds, "items")
cmbItemName.DataSource = ds.Tables("items")
cmbItemName.ValueMember = "item_id"
cmbItemName.DisplayMember = "item_name"
cmbItemName.SelectedIndex = -1

Catch ex As Exception
MessageBox.Show("Couldnot load Item name", "Error")
Finally
da.Dispose()
ds.Dispose()
End Try

End Sub

I have 2 combobox cmbgroupname and cmbitemname. both from mssql database is populated...on selecting groupname ,,,itemname is populated for that groupname. Im using vb2008


I executed above code in this ..first time when a group name is selected from dropdown ..then in above event it gives empty message then again display text...i.e on first time selection cmbitemname doest have data but if i again select same group name then cmbitemname has data. Is there any problem in my coding ? Im uisng above event bcoz i want to fill itemname only when user selects item in groupname.

Plz help

Viewing all articles
Browse latest Browse all 27514

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>