Accessing dynamically created checkbox in user control from container page
<p>I am building a wizard in asp.net. I have an main aspx page which will have NEXT and PREVIOUS button for Navigation. On click of each NEXT or PREVIOUS appropriate user control will be loaded. </p>

<p>In one user control I have to create dynamic checkboxes as shown below:</p>

<pre><code>    Public Class ucQuestion
    Inherits System.Web.UI.UserControl


#Region "UserControl Events"

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            If Not (Page.IsPostBack) Then
                AddControls(0)
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

#End Region
Protected Friend Sub AddControls(ByVal iListQuestionCount As Integer)
        Try
            Dim oExam As New BusinessObject.Wizard.ExamVM
            If (System.Web.HttpContext.Current.Session(BusinessLayer.Constants.WizardObjectCollection) IsNot Nothing) Then
                oExam = DirectCast(System.Web.HttpContext.Current.Session(BusinessLayer.Constants.WizardObjectCollection), BusinessObject.ExamWizard.ExamVM)
            End If

            'divQuestion.Controls.Clear()

            Dim ctrl As New Literal

            ctrl.ID = "lit" + iListQuestionCount.ToString()
            ctrl.Text = oExam.Wizard.ExamQuestions(iListQuestionCount).Label
            divQuestion.Controls.Add(ctrl)

            For iLoopChildCount As Integer = 0 To oExam.Wizard.ExamQuestions(iListQuestionCount).Choices.Count - 1
                Dim childctrl As New CheckBox
                'childctrl.AutoPostBack = True
                childctrl.ID = "chk" + (iLoopChildCount + 1).ToString()
                childctrl.Text = oExam.Wizard.ExamQuestions(iListQuestionCount).Choices(iLoopChildCount).Label
                childctrl.Checked = oExam.Wizard.ExamQuestions(iListQuestionCount).Choices(iLoopChildCount).IsSelected
                'AddHandler childctrl.CheckedChanged, AddressOf OnCheckedClick
                divQuestion.Controls.Add(childctrl)
            Next

        Catch ex As Exception
            Throw ex
        End Try
    End Sub
</code></pre>

<p>NoW the problem is in my Main.aspx page if user has selected any checkbox in usercontrol I want to save the value in session on NEXT button Navigation click event.</p>

<p>I tried following code in NEXT Button Click but it was unsucessfull.</p>

<pre><code>For iLoopChildCount As Integer = 0 To oExamQuestions(ListIndex).Choices.Count - 1
                Dim ctrl As Control
                If (ucQuestion1.FindControl("chk" + (iLoopChildCount + 1).ToString()) IsNot Nothing) Then
                    ctrl = DirectCast(ucQuestion1.FindControl("chk" + (iLoopChildCount + 1).ToString()), CheckBox)
                    If (DirectCast(ctrl, CheckBox).Checked) Then
                        oBallotQuestions(ListIndex).Choices(iLoopChildCount).IsSelected = True
                    End If
                End If
            Next
</code></pre>
