|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Listbox selected items to string arrayHi
I am trying to pass the selected items from a multiselect listbox to a string array. Can any body give me a start. Thanks Colin Williams Assuming you are talking about ListBox ASP.NET Control:
ArrayList al = new ArrayList (); foreach (ListItem li in ListBox1.Items) { if (li.Selected) al.Add (li.Value); } String[] s = (string[])al.ToArray (typeof (string)); Array "s" will have the strings selected from the ListBox. "Colin Williams" <colinwilliams***@msn.com> wrote in message I am trying to pass the selected items from a multiselect listbox to anews:1161202656.229981.117180@m73g2000cwd.googlegroups.com... Hi string array. Can any body give me a start. Thanks Colin Williams Sorry, forgot to add: in case of Windows Forms ListBox, loop through
SelectedItems or SelectedIndices to fetch each selected item's text and add it to an ArrayList and finally convert it to String array as shown in my previous post. "Colin Williams" <colinwilliams***@msn.com> wrote in message I am trying to pass the selected items from a multiselect listbox to anews:1161202656.229981.117180@m73g2000cwd.googlegroups.com... Hi string array. Can any body give me a start. Thanks Colin Williams Thanks
Siva M wrote: Show quote > Sorry, forgot to add: in case of Windows Forms ListBox, loop through > SelectedItems or SelectedIndices to fetch each selected item's text and add > it to an ArrayList and finally convert it to String array as shown in my > previous post. > > "Colin Williams" <colinwilliams***@msn.com> wrote in message > news:1161202656.229981.117180@m73g2000cwd.googlegroups.com... > Hi > I am trying to pass the selected items from a multiselect listbox to a > string array. Can any body give me a start. > Thanks > > Colin Williams |
|||||||||||||||||||||||