Start New Discussion within our Web Development Community

Hi! I need a help!! I'm currently working on an Online Election.

Basically, what i want is to output the list of candidates in every position in my database.
I output the list of the positions in a dynamic labels and the list of candidates in a dynamic dropdownlist.

For the position and candidates, I have the code of it and it works pretty well.

My problem is, I want to get the value of the selectedValue of the dropdownlist. In order for me to have it, i need to have an event handler.

Here is my code for the dynamic dropdownlist..

            sqlSearch3 = "Select candidateName from tblcandidates where positionID=" & lbl(num2).Text & ""
            sqlCmd3 = New SqlCommand(sqlSearch3, sqlCon3)
            sqlDr3 = sqlCmd3.ExecuteReader

            dropdown(num3) = New DropDownList

            While sqlDr3.Read
                dropdown(num3).ID = "dd" & num3.ToString
            End While

            sqlDr3 = Nothing
            sqlSearch3 = Nothing
            sqlCmd3 = Nothing

            Dim spacer As LiteralControl = New LiteralControl("<br /><br />")

for the AddHandler dropdown(num3).selectedIndexChanged, AddressOf DD_indexchanged I know that it is for the event handler BUT when i have this

Protected Sub DD_texchanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim value As String = CType(sender, DropDownList).selectedValue
    lbl1.text = value
End Sub

I can't see the value of the selectedValue of the dropdownlist..

Please Help me.. Thank YOu!

This article has been dead for over six months. Start a new discussion instead.