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.FindC ontrol("Li stView2"), ListView)
For Each row As ListViewItem In ListView2.Items
Dim hfSpeciesID As HiddenField = DirectCast(row.FindControl ("hfSpecie sID"), HiddenField)
Dim SpeciesID As String = hfSpeciesID.Value
Dim tbHowMany As TextBox = DirectCast(row.FindControl ("tbHowMan y"), 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!
<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.FindC
For Each row As ListViewItem In ListView2.Items
Dim hfSpeciesID As HiddenField = DirectCast(row.FindControl
Dim SpeciesID As String = hfSpeciesID.Value
Dim tbHowMany As TextBox = DirectCast(row.FindControl
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER