Dropdownlistbox runtime selection

dominico

Well-known member
Joined
Mar 9, 2005
Messages
57
Programming Experience
3-5
I have this dropdownlistbox control on my webform which has a dozen of items binding to it. After I do an update on a selected item, I reset the list and the problem is that the item that was updated is no longer being selected or highlighted.

How do I make the list programatically go back and highlight the item that I was updating it ?

I went though all the dropdownlistbox methods but no luck.
Please advise,

Thank you.
 
Last edited:
use viewstate and save your selected index in it. After your update go back and set the selectedIndex property of the list box to the value in viewstate.

Me.ViewState("Index") = ListBox1.SelectedIndex

'
Update / process
'

ListBox1.SelectedIndex = Me.ViewState("Index")

Hope this is helps
 
Back
Top