Link to home
Start Free TrialLog in
Avatar of mugsey
mugseyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

nested listview how to iterate through child listview control

I have nested listview (see below)

How can I iterate through child listview ?

I am using
   
    ListView ChildListView = (ListView)parentListView.FindControl("childListView");   //THIS IS ALWAYS NULL!

    foreach (ListViewDataItem item in ChildListView.Items)
        {
       
        }


I cannot get a reference to the child listview - how can I solve this?

<asp:ListView ID="parentListView" runat="server"  
        <LayoutTemplate>
                <asp:PlaceHolder ID="itemPlaceholder" runat="server">                   </asp:PlaceHolder>
        </LayoutTemplate>
        <ItemTemplate>
                <!-- title goes here -->
                <asp:ListView ID="childListView" runat="server" 
                        <LayoutTemplate>
                                <asp:PlaceHolder ID="itemPlaceholder" .....
                                        </LayoutTemplate>
                                    <ItemTemplate>
                                    </ItemTemplate>

Open in new window

Avatar of Faizan Sarwar
Faizan Sarwar
Flag of United Kingdom of Great Britain and Northern Ireland image

on which event you trying to get reference below
ListView ChildListView = (ListView)parentListView.FindControl("childListView");  
Avatar of mugsey

ASKER

I am not using any of the listview events - you see I am inserting a new entity into the database

So I have an addbutton event

Then I want to iterate through the child listview
ASKER CERTIFIED SOLUTION
Avatar of Dabas
Dabas
Flag of Australia 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