tags:

views:

67

answers:

2

Hi,

I am using vb.net language

I have a dropdownlist, which is filled by below pattern

"Smith,James" so first one is surname and second after "," is firstname

I have two textboxes for surname and firstname. Now I want to fill the textbox when dropdownlist is changed.

I mean when user changes the dropdownlist the selected text in dropdown will be filled in related textboxes.

so my result will be like this

surname.text = "Smith" firstname.text = "James"

Please use vb.net code for this

Thanks.

Best Regards, MS

A: 
Private Sub comboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)

    Dim value As String = TryCast(Me.comboBox1.SelectedItem,String)

    If (Not value Is Nothing) Then
        Dim cells As String() = value.Split(New Char() { ","c })
        If ((Not cells Is Nothing) AndAlso (cells.Length = 2)) Then
            surname.Text = cells(0)
            firstname.Text = cells(1)
        End If
    End If

End Sub
najmeddine
A: 

Something like that should work:

surname.text = dropdownlist.SelectedItem.ToString().Split(",")(0)
firstname.text = dropdownlist.SelectedItem.ToString().Split(",")(1)
Mr. Brownstone
Thanks Dear, It worked for me! Cheers!
MKS