ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 14th, 2003, 08:35 AM
petermaz petermaz is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 4 petermaz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Drop Down List problems

I have a problem when passing the selected text from a databound dropdownlist. No matter which item that you select in the list the first item is always returned in the customerdrop.selecteditem.text.

How do i get the actual 'selected item' back?

Code is below! I call the contactshow sub to populate the dropdownlist, and this in turn calls the bindlist sub.

Button2_click should return in the path the selecteditem value from dropdownlist (contactdrop).



Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Response.Redirect("call.aspx?customer=" & Trim(CustomerDrop.SelectedItem.Text) & "&contact=" & Trim(ContactDrop.SelectedItem.Text))
End Sub

Sub contactshow()
Dim strcustomer As String
strcustomer = Request.QueryString("customer")
Addnewcontact.Visible = True
ContactDrop.Visible = True
Button2.Visible = True
Button1.Visible = False
CustomerDrop.Items.Add(strcustomer)
CustomerDrop.Enabled = False
ContactDrop.DataTextField = "name"
ContactDrop.DataValueField = "cust_ID"
BindList()
End Sub


Sub BindList()
Dim strcustomer As String
strcustomer = Request.QueryString("customer")
Dim connect As OleDbConnection = New OleDbConnection(dsn)
Dim myCommand As OleDbCommand = New OleDbCommand("select contacts.name, contacts.cust_ID from contacts, customer where customer.cust_name = '" & strcustomer & "'", connect)
Dim myDataReader As OleDbDataReader
Try
connect.Open()
myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
ContactDrop.DataSource = myDataReader
ContactDrop.DataBind()
Catch myException As Exception
Response.Write("An error has occurred: " & myException.ToString())
Finally
If Not myDataReader Is Nothing Then
myDataReader.Close()
End If
'ContactDrop.Items.Insert(0, "Select an Item")
'ContactDrop.SelectedIndex = 0
End Try
End Sub

Cheers

Pete

Reply With Quote
  #2  
Old July 14th, 2003, 09:07 AM
kkong's Avatar
kkong kkong is offline
Monkey Magic
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: UK
Posts: 103 kkong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to kkong
Hi,

what happens if you try customerdrop.value

Kong.

Reply With Quote
  #3  
Old July 14th, 2003, 09:21 AM
petermaz petermaz is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 4 petermaz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
there is no customerdrop.value property. If you use the sleected value then the same thing happens but witht the first value rather than the first text field

Reply With Quote
  #4  
Old July 14th, 2003, 05:11 PM
kkong's Avatar
kkong kkong is offline
Monkey Magic
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: UK
Posts: 103 kkong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to kkong
Hi,

ok here's the answer.

Code:

inttest = test.selectedIndex
	
msgbox  test.Options(inttest).text


Kong.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Drop Down List problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway