This is what you have to do..
Do one step at a time.
1.Select the listbox and
SET THE AUTO POSTBACK PROPERTY TO TRUE.
This will trigger an event and everytime you make a different selection in the Listbox and LISTBOX.SelectedIndexChanged event will be triggered.
2.In the page load,do what you are doing.Dont change anything
3.Now double click the Listbox and Enter these codes.
Set the Listbox1.SelectedItem.Text to a String.
Dim Newstr As String
Newstr = Listbox1.SelectedItem.Text
Dim cnn As SqlConnection
Dim cnn As New SqlConnection("Data Source= DeskTop; Initial Catalog=Northwind; Trusted_Connection=Yes")
Dim cmd As SqlCommand
cmd = New SqlCommand("GettingParamForDDL", cnn)
cmdTest.CommandType = Data.CommandType.StoredProcedure
cmdTest.Parameters.Add(New SqlParameter("@PARMHannaMoos", SqlDbType.VarChar)).Value = Newstr
cnn.Open()
Dim dreader1 As SqlDataReader
dreader1 = cmd.ExecuteReader()
ddl.Items.Add("SELECT A VALUE")
Dim firstrowfortrack As Boolean = True
While dreader1.Read()
ddl.Items.Add(New ListItem(dreader1(0).ToString()))
If (firstrowfortrack) Then
firstrowfortrack = False
End If
End While
dreader1.Close()
cnn.Close()
Remember.I'm just typing this code..I havent tested it.
I think this is what you need.
If you get some errors,then post the error.We should be able to help you.
Hope it helps