Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

nested listview how to iterate through child listview control

Posted on 2008-11-06
3
Medium Priority
?
2,631 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:mugsey
3 Comments
 
LVL 13

Expert Comment

by:sm394
ID: 22897375
on which event you trying to get reference below
ListView ChildListView = (ListView)parentListView.FindControl("childListView");  
0
 

Author Comment

by:mugsey
ID: 22897485
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
0
 
LVL 27

Accepted Solution

by:
Dabas earned 2000 total points
ID: 22908636
Hello mugsey,

Lets assume that your parentListView has several items.
Each one of them has a childLIstView. Which one of these childListViews are you referring to?

Somehow you have to use the Selected item in your code

My snippet might give you an idea

Regards,

Dabas
ListViewDataItem ChildDataItem = parentListView.Items[parentListView.SelectedIndex].DataItem
//This ChildDataItem probably will lead you to your child list view

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month20 days, 15 hours left to enroll

810 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