Problem binding a datatable to a combo box

I have a two combo boxes that are bound to data tables using the two procedures below.  

The first populates a combo box with a list of codes for a given project  The second box is populated with a list of items for the selected code in the first box.

The fist box's display member seems to be setting correctly however the value member does not.

As I load the first box the SelectedIndexChanged event fires off as it is being filled and i think this is what is causing the issue.  If i run in debug mode, the cmbActivityCode.SelectedValue is set to "System.Data.DataRowView"

Any help would be appreciated!

Thanks!


Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
 
        Dim db As New DBConnection
        Dim dt As DataTable = db.GetCodeList(txtProjectID.Text)
        cmbActivityCode.BeginUpdate()
        cmbActivityCode.DataSource = dt.DefaultView
        cmbActivityCode.DisplayMember = "ActivityCode"
        cmbActivityCode.ValueMember = "ActivityCode"
        cmbActivityCode.EndUpdate()
    End Sub
 
Private Sub cmbActivityCode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbActivityCode.SelectedIndexChanged
        Dim db As New DBConnection
        Dim dt As DataTable = db.GetItemList(txtProjectID.Text, cmbActivityCode.SelectedValue.ToString)
        cmbItemNumber.BeginUpdate()
        cmbItemNumber.DataSource = dt.DefaultView
        cmbItemNumber.DisplayMember = "ItemNumber"
        cmbItemNumber.ValueMember = "ItemNumber"
        cmbItemNumber.EndUpdate()
 
    End Sub

Open in new window

LVL 2
WinkITAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.