c# - Getting all selected values from an ASP ListBox -


I have an ASP listbox in which the selection mode is set to "multiple". Is there any way to re-delete all the selected elements and not just the last one?

  & asp: listbox id = "lstcart" runat = "server" height = "135px" width = "267px" selection mode = "multiple" & gt; & Lt; / Asp: list box & gt; Using the   

lstCart.SelectedIndex , the last element (expected) comes back. Is there anything that will choose me all?

This is for a web form.

You can use the results and the loop, then accessing each through item archive You can. Alternatively, you can loop through all items and check them out.

  // GetSelectedIndices foreach (ListBox1.GetSelectedIndices ()) in the list {// ListBox1.Items [i] ...} // item archive foreach (ListItem item in ListBox1.Items) {If (item.elected) {// item ... selected} item archive (must enter item) // LINQ List1box in ListItem item from var query = I where item. Select the selection item; Foreach (list item item in query) {// item ...} // LINQ lambda syntax var query = ListBox1.Items.Cast & lt; ListItem & gt; (). Where (item => items selected);  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -