473,799 Members | 2,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DropDownList won't select item...

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_S electedIndexCha nged(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
DropDownList1.S electedIndexCha nged

Me.txtSelection .Text = Me.DropDownList 1.SelectedItem. Text

End Sub

Private Sub btnSelectIt_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSelectIt.Cli ck

Me.lblSelection .Text = "You chose: " + DropDownList1.S electedItem.Tex t
End Sub

Aug 31 '06 #1
2 1859
JamesW
Wrap the dropdownlist in the pageload and check for postback
Patrick

"JamesW" <DO_NOT_SPAM!@# $*********@bigp ond.net.au!@#@! wrote in message
news:#h******** ******@TK2MSFTN GP03.phx.gbl...
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_S electedIndexCha nged(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
DropDownList1.S electedIndexCha nged

Me.txtSelection .Text = Me.DropDownList 1.SelectedItem. Text

End Sub

Private Sub btnSelectIt_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSelectIt.Cli ck

Me.lblSelection .Text = "You chose: " + DropDownList1.S electedItem.Tex t
End Sub



Aug 31 '06 #2
Thanks Patrick that did the trick!

Code:
If Not IsPostBack Then

DropDownList1.D ataSource = custName

DropDownList1.D ataValueField = "CustID"

DropDownList1.D ataTextField = "Name"

DropDownList1.S electedIndex = -1

DropDownList1.D ataBind()

End If

"Patrick.O. Ige" <na********@hot mail.comwrote in message
news:u1******** ******@TK2MSFTN GP05.phx.gbl...
JamesW
Wrap the dropdownlist in the pageload and check for postback
Patrick

"JamesW" <DO_NOT_SPAM!@# $*********@bigp ond.net.au!@#@! wrote in message
news:#h******** ******@TK2MSFTN GP03.phx.gbl...
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_S electedIndexCha nged(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
DropDownList1.S electedIndexCha nged

Me.txtSelection .Text = Me.DropDownList 1.SelectedItem. Text

End Sub

Private Sub btnSelectIt_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSelectIt.Cli ck

Me.lblSelection .Text = "You chose: " + DropDownList1.S electedItem.Tex t
End Sub



Sep 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
2471
by: Julia Hu | last post by:
Hi, I have a datagrid, and in different rows I need to programmatically bind different type of controls and load data into these controls. For example,in the first row I need to bind data into a textbox, and in the second row I need to bind data into a dropdownlist...It all depends on the data I select from the database. I cannot use TemplateColumn because it has to be the same type of control for one column.
3
4379
by: Tim::.. | last post by:
Can someone please tell me how I go about preselecting an item in a drop drown list when I click the Edit Command in a datagrid? I have tried the following but it doesn't work for me! I would be really grateful for any assistance! Thanks
10
10773
by: dhnriverside | last post by:
Hi guys Still having a problem with this dropdownlist. Basically, I've got 4. The first 2 work fine, then my code crashes on the 3rd. ddlEndTimeHour.Items.FindByValue(endTime).Selected = true; Where endTime is a string containing "15".
2
2023
by: jason | last post by:
Pardon my ignorance on this. The below code works, except, when I edit a record and update the two drop downs take the first entry in the dropdownlist if not selected. I'd also like the dropdown to show the current value in edit mode. I'm sure this is a common question. I've reviewed several related post and tried them out to no avial. Some of the offerings in listgroup look right on, but are not clear on where to handle the suggested...
2
16101
by: glenn | last post by:
Hi folks, I am trying to determine which item in a DropDownList Web control has been selected. I have posted an OnSelectedIndexChanged subroutine in my code with a reference to the subroutine in my asp tag as shown here: <asp:DropDownList id="ddlTo" runat="server"
15
3132
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an OnSelectedIndex event is not fired if you select the first item. Does anyone know of an easy way to do this?
11
5816
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
3
5286
by: Iain | last post by:
Hi All I have 2 DropDownList boxes on a page. The first (id= "Operation") is populated on PageLoad with the contents of a database table. The second id="WorkStations" will not be populated until the first has been changed The definitions are below.
1
2707
by: mark4asp | last post by:
I moved a page to another web-site and now it's broke! I had 5 pages in their own web-site. These pages have now been moved to another web-site. Everything is fine except that one of the pages, which I had trouble with in the past (i.e. same problem), is now partly broke. The paging no longer fully works in the gridview. The gvAwarded_RowDataBound code works to load the ddlPager with the correct number of pages.
0
1812
by: Moneypenny | last post by:
Hi there, I have a Gridview control which has a dropdownlist in every row. The dropdowns are populated dynamically from a database (so the content is different in each row. There is also a select button for each row so that the the user can choose a row and the values will be added to a shopping cart. My problem is that the page loads fine and everything is showing as it should be. However, when I select a row the dropdownlist for that row...
0
9689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10269
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10248
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.