views:

2105

answers:

3

I have two list views. In the Item command event of the first Listview i am showing the second list view in modal popup using ajaxtoolkit.

protected void lvSelection_ItemCommand(object sender, ListViewCommandEventArgs e)
{
    this.lvPopup.Visible = true;
    this.lvPopup.DataSource = linqdataSource;
    this.lvPopup.DataBind();

    this.mdlPopup.Show();
}

Now in the itemcommand event of the second list view I need to change the content of the selected item in the first listview.

Is it possible to do that?

A: 

I'd think that if you were to set the CommandName of the selector button in the first ListView to "Select" - from the second list view's ItemCommand event, you should be able to alter either the SelectedItemTemplate or the current item for the selected item in the first list.

protected void lvPopup_ItemCommand(object sender, ListViewCommandEventArgs e)
{

   lvSelection.SelectedItemTemplate = "<div>woohoo!</div>";
   // OR...
   lvSelection.Items[lvSelection.SelectedIndex].SkinID = "SomeNewSkinForExample";


   mdlPopup.Hide();

}
Scott Ivey
+1  A: 
protected void lvPopup_ItemCommand(object sender, ListViewCommandEventArgs e)
{
    // Set the text of the first list view item to the selected item 
    // of the second list view.
    lstView1.Items[lstView1.SelectedIndex].Text = 
        lstView2.Items[lstView2.SelectedIndex].Text
}
Gavin Miller
Might be my question itself is confusing...The requirement is to change the lstView1's selected item contents after the user selects an item from listview2.
In the initial view the lstView1 will be populated with categories.When the user selects a category, the sub categories would popup in ListView2. After selecting the sub categories..the main Listview1's selected item would show the selected subcategories.
A: 

Have you already tried to dynamically generate the items of the List?

On the event code of the 1st list, clear the Items from the 2nd list and populate it with whatever logic suits you.

Luis Filipe