Link to home
Start Free TrialLog in
Avatar of Abdu_Allah
Abdu_Allah

asked on

Get the prevoius selected item for the ListBox in SelectedIndexChanged function

Hi, Is it possible to get the selected prevoius selected(the one before the current one) item for the ListBox in SelectedIndexChanged function?
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Abdu_Allah
Abdu_Allah

ASKER

It will be change also once the the user select anothe item.
>> It will be change also once the the user select anothe item.
Why ?
When you click on a item you store that value(index) on a session. After you do all your work, you copy to another one (the previous selected item).
This way you will have the actual and the old one.
<!-- richText -->
Can you explain your idea with code please? because whenever you copy it the prevoius one will deleted!
 

In the SelectedIndexChanged event you can do:

Session("old") = Session("new")
Session("new") = Me.ListBox1.SelectedIndex ' or you can use a value
 
This way you store the previous value (or in this case index) of the listbox and the new one.
 

PS: Don't forget to set the AutoPostBack in the listbox to true
I want the old selected Item in SelectedIndexChanged function.
Don't understand!
You just have to change:
Session("new") = Me.ListBox1.SelectedIndex
with
Session("new") = Me.ListBox1.SelectedItem.Text
 
Or do I understood it wrong ?
 
>Or do I understood it wrong ?
Exactly.
>> Exactly
Can you explain ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
But by this way you cannot get the old value if you select a new one!
Yes you can. You're storing to hidden field the value selected when your listbox get focus. When you click to another one, if you get the hidden field value you get the previous item value.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial