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

Discussion in '.NET' started by msimmons, Jul 16, 2009.

  1. msimmons

    msimmons

    Joined:
    Jul 16, 2009
    Messages:
    1
    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
    msimmons, Jul 16, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SirPoonga
    Replies:
    2
    Views:
    738
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    996
    weiwei
    Jan 5, 2007
  3. xxbmichae1@supergambler.com

    Auto Drop down a Drop Down List

    xxbmichae1@supergambler.com, Nov 22, 2005, in forum: Javascript
    Replies:
    5
    Views:
    247
    xxbmichae1@supergambler.com
    Nov 23, 2005
  4. scott@dettcom.com

    Multiple select drop down poplulating sub drop down

    scott@dettcom.com, Nov 8, 2006, in forum: Javascript
    Replies:
    3
    Views:
    273
    scott@dettcom.com
    Nov 9, 2006
  5. teser3@hotmail.com
    Replies:
    0
    Views:
    160
    teser3@hotmail.com
    Jan 28, 2009
Loading...

Share This Page