Link to home
Start Free TrialLog in
Avatar of AJ0718
AJ0718

asked on

Read Values from Nested ListView

I am using a nested ListView as a data entry form and have everything bound exactly right.  The basic format is:
<ListView1>
<Item Template>
<ListView2>
<some controls in ListView2 with values from database and user-entered>

The problem comes on submit when I am trying to get values from the form.  I am looping through both listviews but debug shows I am not finding ListView2 and consequently none of its controls.  Can someone please tell me where I am going wrong?

Dim arrSpecies As New ArrayList()
        For Each item As ListViewItem In ListView1.Items
            Dim ListView2 As ListView = DirectCast(ListView1.FindControl("ListView2"), ListView)
            For Each row As ListViewItem In ListView2.Items
                Dim hfSpeciesID As HiddenField = DirectCast(row.FindControl("hfSpeciesID"), HiddenField)
                Dim SpeciesID As String = hfSpeciesID.Value
                Dim tbHowMany As TextBox = DirectCast(row.FindControl("tbHowMany"), TextBox)
                Dim Individuals As String = tbHowMany.Text
                If Individuals <> "" Then
                    Dim v As String = SpeciesID & "-" & Individuals
                    arrSpecies.Add(v)
                End If
            Next
        Next
Thanks for your help!
ASKER CERTIFIED SOLUTION
Avatar of jagssidurala
jagssidurala
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AJ0718
AJ0718

ASKER

Fantastic!  Thanks so much.