listBox selected values
-
hi , i have some problem in getting the selected values of my ListBox :doh: i use some code like this :
ListBox1.SelectedValue
but it just gives me the first selected value ! my list box is in multiple mode and user can select some coises !!! how can i get the whole of selected values without using for cycle ?! -
hi , i have some problem in getting the selected values of my ListBox :doh: i use some code like this :
ListBox1.SelectedValue
but it just gives me the first selected value ! my list box is in multiple mode and user can select some coises !!! how can i get the whole of selected values without using for cycle ?!This should help:
List<ListItem> LlstSelectedItems = new List<ListItem>();
for(int LiCount = 0; LiCount < ListBox1.Items.Count; LiCount++)
{
if (ListBox1.Items[LiCount].Selected)
LlstSelectedItems.Add(ListBox1.Items[LiCount]);
}Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
hi , i have some problem in getting the selected values of my ListBox :doh: i use some code like this :
ListBox1.SelectedValue
but it just gives me the first selected value ! my list box is in multiple mode and user can select some coises !!! how can i get the whole of selected values without using for cycle ?!u use now listbox1.selecteditem.text fine sure work now