DropDownList won't select item...

  • Thread starter Thread starter JamesW
  • Start date Start date
J

JamesW

Hi there.

Vstudio 2003, IE 6.0

I have an asp connected to an Access database.

A DropDownList on the page shows names from the Db.

When the user selects a name from the DropDownList I want the selected name
to appear in a text box on the page.

I have tried setting AutoPostBack etc. but the only selection to register is
always the first item in the list.

I have tried activating the selection by a button on the page too. (See Code
Below). Only the first item in the list is selected.

T.I.A for any help.

The Code:

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged

Me.txtSelection.Text = Me.DropDownList1.SelectedItem.Text

End Sub

Private Sub btnSelectIt_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSelectIt.Click

Me.lblSelection.Text = "You chose: " + DropDownList1.SelectedItem.Text


End Sub
 
Thanks Patrick that did the trick!

Code:
If Not IsPostBack Then

DropDownList1.DataSource = custName

DropDownList1.DataValueField = "CustID"

DropDownList1.DataTextField = "Name"

DropDownList1.SelectedIndex = -1

DropDownList1.DataBind()

End If
 
Back
Top