Results 1 to 2 of 2

Thread: Problem with selectionchangecommited of combobox

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2013
    Posts
    37

    Problem with selectionchangecommited of combobox

    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Problem with selectionchangecommited of combobox

    You might like to follow the CodeBank link in my signature and check out my thread on Master/Detail Data-Binding. Unless you have a large amount of data in the child table, that's the easiest option.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width