ASP.NET - selectedItems is not acces in listview

Asked By msakt on 05-Jun-12 12:53 AM
error occur does not contain defenition for selecteditems and no extension method
Jitendra Faye replied to msakt on 05-Jun-12 12:58 AM
To get selectedItems in ListView use this code-

ListView.SelectedListViewItemCollection items= this.ListView1.SelectedItems;
Neha Garg replied to msakt on 05-Jun-12 12:59 AM
Hi...msakt,


first you have to bind the Listview1...


var selectedQuery = listBox.Items.Cast<ListItem>().Where(item => item.Selected);

See the complete solution on the below link:

http://www.codeproject.com/Articles/10008/Data-binding-a-ListView
S K replied to msakt on 05-Jun-12 01:05 AM
Simply try this line
string item =  lvList.SelectedItems(0).Text ;

hope this helps you
Chintan Vaghela replied to msakt on 05-Jun-12 01:06 AM

Hi Frndz,

Move list view selected Item to other list view then try to use following code

private static void MoveSelectedItems(ListView source, ListView target)

    {

      while (source.Items.Count > 0)

      {

        ListViewDataItem temp = source.Items[0];

        source.Items.Remove(temp);

        target.Items.Add(temp);

      }

    }

 

Hope this helpful!

Thanks

 

 

 

 

msakt replied to Chintan Vaghela on 05-Jun-12 01:17 AM
can u explain briefly.....bcoz code run but no output....