Wrox Programmer Forums
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 6th, 2007, 10:45 PM
Registered User
 
Join Date: Feb 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested Repeater Using Stored Procedure kwilliams ASP.NET 2.0 Professional 1 July 21st, 2008 06:49 PM
How to dispaly attributes of xml nested repeater.. vishnu108mishra XML 0 November 15th, 2007 07:38 AM
nested repeater ramonjor ASP.NET 2.0 Basics 0 July 31st, 2007 04:18 AM
nested repeater david_ste ASP.NET 2.0 Professional 0 August 24th, 2006 09:52 AM
Why is Findcontrol Failing on a Repeater Postback? HD95 ASP.NET 1.0 and 1.1 Basics 3 January 27th, 2006 09:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.