I have an ASP ListBox that has the SelectionMode set to "Multiple". Is there any way of retreiving ALL selected elements and not just the last one?
<asp:ListBox ID="lstCart" runat="server" Height="135px" Width="267px" SelectionMode="Multiple"></asp:ListBox>
Using lstCart.SelectedIndex
just returns the last element (as expected). Is there something that will give me all selected?
This is for a web form.
You can use the ListBox.GetSelectedIndices method and loop over the results, then access each one via the items collection. Alternately, you can loop through all the items and check their Selected property.
use GetSelectedIndices method of listbox
try using this code I created using VB.NET :
I hope it helps.