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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> 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 -->
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 -->
ASKER
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
ASKER
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.T ext
Or do I understood it wrong ?
You just have to change:
Session("new") = Me.ListBox1.SelectedIndex
with
Session("new") = Me.ListBox1.SelectedItem.T
Or do I understood it wrong ?
ASKER
>Or do I understood it wrong ?
Exactly.
Exactly.
>> Exactly
Can you explain ?
Can you explain ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER