Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List box to text box

Status
Not open for further replies.

LeoLionHeart

Programmer
Joined
Apr 4, 2006
Messages
45
Location
GB
hi,

I have a web form with a list box and a textbox.

What I want to do is everytime a user changes the item selected in the list box the new item to be displayed in the text box.

Any ideas?

I want to use Jscript for this, otherwise it will be slow.

Any help would be appreciated.
 
You can set the autopostback of the listbox to true and use the code:

Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
TextBox1.Text = ListBox1.Text
End Sub
 
This doesn't work. I have a value of nothing or blank when i set the autopostback to true and use the following.

Code:
    Private Sub lstQual_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstQual.SelectedIndexChanged
        Dim str As ListItem = Me.lstQual.SelectedItem
        Dim a As String = Me.lstQual.SelectedValue
        Me.txtUpDate.Text = Me.lstQual.SelectedValue
    End Sub

Any ideas?
 
Try this:
Code:
Private Sub lstQual_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstQual.SelectedIndexChanged
  txtUpdate.Text = lstQual.SelectedItem.Value
End Sub
..see if that works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top