listbox selected items into an array
-
The Listbox selected items into an array onselected index change i tryed in this way protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { _count++; _items = new string[_count]; _items[_count - 1] = ListBox1.SelectedItem.Text.Trim(); } this gives only the present values alone. Previously selected values are not available in the array help me please its urgent.
Bharani
-
The Listbox selected items into an array onselected index change i tryed in this way protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { _count++; _items = new string[_count]; _items[_count - 1] = ListBox1.SelectedItem.Text.Trim(); } this gives only the present values alone. Previously selected values are not available in the array help me please its urgent.
Bharani
Can you please explain what exactly you want i thing you need previous selection and changed selection both for some comparisation
-
The Listbox selected items into an array onselected index change i tryed in this way protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { _count++; _items = new string[_count]; _items[_count - 1] = ListBox1.SelectedItem.Text.Trim(); } this gives only the present values alone. Previously selected values are not available in the array help me please its urgent.
Bharani
Member 4463285 wrote:
please its urgent
That is a very rude and impolite approach at getting help on this site.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
The Listbox selected items into an array onselected index change i tryed in this way protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { _count++; _items = new string[_count]; _items[_count - 1] = ListBox1.SelectedItem.Text.Trim(); } this gives only the present values alone. Previously selected values are not available in the array help me please its urgent.
Bharani
Try this,
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { _count++; _items = new string[_count]; if (Session["Items"]!=null) { _items = Session["Items"]; } _items[_count - 1] = ListBox1.SelectedItem.Text.Trim(); Session["Items"] = _items; }
Normal variable's values will be clear once the response is done. You can use Static variables but Static variable would share the values to other users also. But use a Session variable to maintain the items.
Castle Rider My: Website | Yahoo Group | Blog Spot
-
The Listbox selected items into an array onselected index change i tryed in this way protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { _count++; _items = new string[_count]; _items[_count - 1] = ListBox1.SelectedItem.Text.Trim(); } this gives only the present values alone. Previously selected values are not available in the array help me please its urgent.
Bharani
Member 4463285 wrote:
_items = new string[_count];
This may be cause of the problem. Every time you are initializing the array.So all items automatically erased.
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE. How to post a question