?
Solved

Read Values from Nested ListView

Posted on 2011-09-24
2
Medium Priority
?
405 Views
Last Modified: 2012-06-21
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!
0
Comment
Question by:AJ0718
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
jagssidurala earned 2000 total points
ID: 36594419
Change your code like below,
i have higjlighted the code change

Dim arrSpecies As New ArrayList()
        For Each item As ListViewItem In ListView1.Items
            Dim ListView2 As ListView = DirectCast(item.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
0
 

Author Closing Comment

by:AJ0718
ID: 36595064
Fantastic!  Thanks so much.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

764 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