Solved

Nested Listview OnItemDataBound

Posted on 2015-01-21
1
55 Views
Last Modified: 2016-01-30
I have a nested listview control.  The OnItemDataBound command for the parent passes a parameter to the child listview and populates it.  This all works fine.  See test app at http://cobirds.org/CFO/Conventions/TestList.aspx.

My problem comes when I try to apply an OnItemDataBound command to the child listview.  My code works fine for the first children but is not completing the loop for the child in the last parent.  In my test cited above I added counters.  There should be four parents and 44 children but the last three are never read.  Do any of you experts have an idea of why it would bounce out at the last parent?  For demo purposes I have changed things to close a trip when there is one person registered.  You can see that it works fine on the first three dates but not the last one.

Protected Sub lvNested_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.ListViewItemEventArgs)
        Dim child As Integer = 0
        For Each item As ListViewItem In ListView1.Items
            Dim lvNested As ListView = DirectCast(item.FindControl("lvNested"), ListView)
            child += lvNested.Items.Count
            For Each row As ListViewItem In lvNested.Items
                Dim hfMaxNo As HiddenField = DirectCast(row.FindControl("hfMaxNo"), HiddenField)
                Dim hfRegistered As HiddenField = DirectCast(row.FindControl("hfRegistered"), HiddenField)
                Dim cbSelect As CheckBox = DirectCast(row.FindControl("cbSelect"), CheckBox)
                Dim ClosedLabel As Label = DirectCast(row.FindControl("ClosedLabel"), Label)
                Dim MaxNo As Integer = 1
                Dim Registered As Integer = hfRegistered.Value
                If Registered > MaxNo Then
                    ClosedLabel.Text = "Trip Closed!  "
                    cbSelect.Visible = False
                Else
                    ClosedLabel.Text = ""
                    cbSelect.Visible = True
                    cbSelect.Enabled = True
                End If
            Next
        Next
        lblTestTrips.Text = "Parent: " & ListView1.Items.Count & " Children: " & child

Open in new window

0
Comment
Question by:AJ0718
1 Comment
 

Accepted Solution

by:
AJ0718 earned 0 total points
ID: 40565681
FYI - I managed a workaround by changing my nested listview to a repeater control and all is well.  This just doesn't seem like a real solution, however.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question