FindControl in nested repeater
I keep getting a System.NullReferenceException error when I try to find a control in my nested repeater(rptProducts). I have an image button that on click I need to check to see if any checkboxes have been checked in the nested repeater, I will eventually store this information in a cookie.
Protected Sub ibHR_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibHR.Click
Dim rptr As Repeater
Dim d As RepeaterItemEventArgs
rptr = CType(d.Item.FindControl("rptProducts"), Repeater)
Dim rc As RepeaterItemCollection = rptr.Items
For Each Item As RepeaterItem In rc
Dim MyCheckBox As CheckBox = CType(Item.FindControl("chkProductID"), CheckBox)
If MyCheckBox.Checked Then
Response.Write("ProductID = " & MyCheckBox.Attributes("ProductID") & "</br>")
End If
Next
Response.End()
End Sub
I think the problem is that it can not find the repeater - because I can not access it by name anywhere in the code behind.
Any help would be appreciated. Thank you.
|