DropDownList won't select item...

Discussion in 'ASP .Net' started by JamesW, Sep 1, 2006.

  1. JamesW

    JamesW Guest

    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
    JamesW, Sep 1, 2006
    #1
    1. Advertising

  2. JamesW
    Wrap the dropdownlist in the pageload and check for postback
    Patrick

    "JamesW" <DO_NOT_SPAM!@#$%!@#@!> wrote in message
    news:#...
    > 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
    >
    >
    >
    >
    >
    Patrick.O.Ige, Sep 1, 2006
    #2
    1. Advertising

  3. JamesW

    JamesW Guest

    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

    "Patrick.O.Ige" <> wrote in message
    news:...
    > JamesW
    > Wrap the dropdownlist in the pageload and check for postback
    > Patrick
    >
    > "JamesW" <DO_NOT_SPAM!@#$%!@#@!> wrote in message
    > news:#...
    > > 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
    > >
    > >
    > >
    > >
    > >

    >
    >
    JamesW, Sep 1, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kathy Burke

    Select dropdownlist item with keyboard?

    Kathy Burke, Dec 18, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    2,831
    Kathy Burke
    Dec 18, 2003
  2. =?Utf-8?B?RGF2aWQ=?=

    DropDownList: Select item based on record? (newbie)

    =?Utf-8?B?RGF2aWQ=?=, Nov 14, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    7,354
    =?Utf-8?B?RGF2aWQ=?=
    Nov 15, 2004
  3. Atreju
    Replies:
    1
    Views:
    5,081
    Anmol
    Jan 9, 2006
  4. Lee
    Replies:
    1
    Views:
    436
    blackstaronline.net
    Feb 22, 2006
  5. John Smith
    Replies:
    2
    Views:
    594
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jun 7, 2006
Loading...

Share This Page