Affecting a dynamically created drop down from another dynamically created drop down.

Joined
Jul 16, 2009
Messages
1
Reaction score
0
In a web application that I am creating, I am dynamically building two columns of drop downs and the number of rows is dependent on the user's selection.
I want the 1st drop down in a row to affect the 2nd in the same row on selection changed.
Here is a sample app I wrote to isolate the problem I am trying to work out:

Code:
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit

        'draw 5 pairs of combo boxes
        For i As Integer = 0 To 4

            'create new combo box
            Dim myComboOne As New DropDownList

            'give the combo box an ID
            myComboOne.ID = "comboOne" & i

            'fill the combo with A -Z
            fillCombo(myComboOne)

            '**add event to combo**
            AddHandler myComboOne.SelectedIndexChanged, AddressOf comboOne_SelectedIndexChanged

            'make combo cause postback
            myComboOne.AutoPostBack = True


            'create new combo box
            Dim myComboTwo As New DropDownList

            'give the combo box an ID
            myComboTwo.ID = "comboTwo" & i

            'fill the combo with A -Z
            fillCombo(myComboTwo)

            'create a literal for display purposes
            Dim myLiteralBR As New Literal
            myLiteralBR.Text = "<br><br>"

            'add the dropdowns to the panel
            pnlOne.Controls.Add(myComboOne)
            pnlOne.Controls.Add(myComboTwo)
            pnlOne.Controls.Add(myLiteralBR)

        Next
    End Sub

    Protected Sub comboOne_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        txtOne.Text = "got here"

        '**here is where I want comboOne0 to affect comboTwo0


    End Sub

    Protected Sub fillCombo(ByRef theCombo As DropDownList)
        For i As Integer = 65 To 90
            theCombo.Items.Add(Char.ConvertFromUtf32(i))
        Next
    End Sub
End Class

Let me know if there is further data I can provide,
M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top