|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
Hi,
what happens if you try customerdrop.value Kong. |
|
#3
|
|||
|
|||
|
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
|
|
#4
|
||||
|
||||
|
Hi,
ok here's the answer. Code:
inttest = test.selectedIndex msgbox test.Options(inttest).text Kong. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Drop Down List problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|