Events in dynamic user controls in ASP 2.0

Discussion in 'ASP .Net Building Controls' started by Ken Nipper, Jan 27, 2006.

  1. Ken Nipper

    Ken Nipper Guest

    I am trying to load x number of the exact same user control on the
    page. I added the event handling in the user control code. The
    problem I have is that the first control loaded works properly but the
    next control does not fire its event handler. I know this sounds
    confusing but basically its in the form of (question then
    dropdownlist/radio buttons with possible answers) multiple times. It's
    a troubleshooting tool.

    Below is the code in the event handler if it helps:
    Protected Sub DropDownList_TextChanged(ByVal sender As Object, ByVal e
    As System.EventArgs) Handles DropDownList.TextChanged
    Dim i As Integer = 0
    Dim nq As String = String.Empty
    nq = nextQuestionArray(Me.DropDownList.SelectedIndex - 1)
    Dim DataClass As New DataHandler
    Try
    Dim index As Integer = 0
    While index < DataClass.selectData(nq).Tables(0).Rows.Count
    Select Case
    CInt(DataClass.selectData(nq).Tables(0).Rows(index).Item(3))
    Case 1
    Dim newcontrol As DropDownUserControl =
    LoadControl("DropDownUserControl.ascx")
    newcontrol.question =
    DataClass.selectData(nq).Tables(0).Rows(index).Item(0).ToString
    newcontrol.secondarytext =
    DataClass.selectData(nq).Tables(0).Rows(index).Item(2).ToString
    newcontrol.values =
    DataClass.selectData(nq).Tables(0).Rows(index).Item(1).ToString.Split(pi
    pe)
    newcontrol.nextquestion =
    DataClass.selectData(nq).Tables(0).Rows(0).Item(4).ToString.Split(pipe)
    Me.Parent.FindControl("contentdiv").Controls.Add(newcontrol)
    Case 2
    Dim newcontrol As RadioButtonsControl =
    LoadControl("RadioButtonsUserControl.ascx")
    newcontrol.question =
    DataClass.selectData(nq).Tables(0).Rows(index).Item(0).ToString
    newcontrol.secondarytext =
    DataClass.selectData(nq).Tables(0).Rows(index).Item(2).ToString
    newcontrol.values =
    DataClass.selectData(nq).Tables(0).Rows(index).Item(1).ToString.Split(pi
    pe)
    Me.Parent.FindControl("contentdiv").Controls.Add(newcontrol)
    End Select
    index += 1
    End While
    Catch ex As Exception
    'Exception handler snipped out
    End Try

    Please reply with any suggestions. Thanks in advance.
     
    Ken Nipper, Jan 27, 2006
    #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. Replies:
    5
    Views:
    5,625
  2. Replies:
    0
    Views:
    606
  3. Ronald
    Replies:
    2
    Views:
    872
    Robbe Morris [C# MVP]
    Jan 17, 2006
  4. dje

    dynamic events on dynamic controls

    dje, Jun 25, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    136
    Robert Koritnik
    Jun 28, 2004
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    420
    Chris
    Aug 30, 2005
Loading...

Share This Page