Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DropDownList won't select item...

Reply
Thread Tools

DropDownList won't select item...

 
 
JamesW
Guest
Posts: n/a
 
      08-31-2006
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





 
Reply With Quote
 
 
 
 
Patrick.O.Ige
Guest
Posts: n/a
 
      09-01-2006
JamesW
Wrap the dropdownlist in the pageload and check for postback
Patrick

"JamesW" <DO_NOT_SPAM!@#$%(E-Mail Removed)!@#@!> wrote in message
news:#(E-Mail Removed)...
> 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
>
>
>
>
>



 
Reply With Quote
 
 
 
 
JamesW
Guest
Posts: n/a
 
      09-01-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> JamesW
> Wrap the dropdownlist in the pageload and check for postback
> Patrick
>
> "JamesW" <DO_NOT_SPAM!@#$%(E-Mail Removed)!@#@!> wrote in message
> news:#(E-Mail Removed)...
> > 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
> >
> >
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView: Filter DropDownList for another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-29-2005 07:44 AM
GridView: Filtr DropDownList from another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-23-2005 01:31 PM
databinding a Dropdownlist to another dropdownlist tshad ASP .Net 8 10-19-2005 10:00 PM
Using a data-bind dropdownlist to populate another data-bind dropdownlist mr2_93 ASP .Net 1 10-02-2005 05:07 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM



Advertisments