Hellooooo... I want to ask a question!

I have Listview1 and in the SelectedItemTemplate I have ListView2. When i click "Select" The Listview2 shows up... and then when i click it again i want it to hide but, i want it check to check if the ListView2 has items to hide the InsertItemTemplate and if it does not have items to show it... I cannot count the items of the 2nd Listview...

I am using this for ListView1 and it works great:

protected void ListView1_DataBound(object sender, EventArgs e)
    {
        if (ListView1.Items.Count == 0)
        {
            ListView1.InsertItemPosition = InsertItemPosition.LastItem;
        }
        else
        {
            ListView1.InsertItemPosition = InsertItemPosition.None;
        }
    }


protected void ListView1_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
    {
        if (ListView1.SelectedIndex == e.NewSelectedIndex)
        {
            e.Cancel = true;
            ListView1.SelectedIndex = -1;
        }
    }

I created ListView2_DataBound event but it does not work.. How can i use that in Listview2? i tried to use FindControl but this only works if i put my ListView2 both in the ItemTempate and in the SelectedItemTemplate..

Recommended Answers

All 2 Replies

You can't access ListView2 from the item template because it doesn't exist in the item template. What exactly are you trying to do in the ItemTemplate that you are needing to access ListView2 for? I couldn't quite make out what your goal is from your post.

Thank you for your answer i just solved this! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.