htm11h
htm11h

Reputation: 1779

populate combo box by consuming web service returning a dataset

I am trying to populate a combo list box with the results of a web service. The web service returns a dataset with two columns. I want to display column one to the user and capture column two with the user selection of an item from the combox.

right now I can display the first column and capture the selection.

Not sure how to add the connection of column two, to the combo box and capture the selection.

any help would be greatly appreciated!!

Code so far....

    myDataSet1 = proxy3.listSuppLang() 

    Dim x As Integer 
    Dim dt As DataTable = myDataSet1.Tables(0) 
    Dim myString As String = "" 

    If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then 
        'some code 
        For x = 0 To dt.Rows.Count - 1 

            myString = dt.Rows(x).Item(0) 

            ComboBox1.Items.Add(myString) 
        Next 
        ComboBox1.Visible = True 
    End If

Upvotes: 0

Views: 833

Answers (1)

htm11h
htm11h

Reputation: 1779

I found this to work adquately....

If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
        'some code
        ComboBox1.DataSource = dt
        ComboBox1.DisplayMember = "textFieldcolumnName"
        ComboBox1.ValueMember = "valueFieldcolumnName"
        ComboBox1.Visible = True
End If

Upvotes: 1

Related Questions