PLEASE? Reorder of listitems only works first time

K

K B

I'm using ASP.NET 2.0 and am still struggling. I use the following code
to reorder items in a listbox. When complete, a Save button saves each
item to a database. Works fine for the first click (runat=Server) but on
subsequent use the item just seems to go anywhere...usually to the top
of the list.

PLEASE, how can I accomplish this using a listbox control and code (not
javascript)?

Dim mSelectedIndex, mOtherIndex As Integer
'do nothing if the first item is selected
If lstQuestions.SelectedIndex <> 0 Then
mSelectedIndex = lstQuestions.SelectedIndex
mOtherIndex = mSelectedIndex - 1
lstQuestions.Items.Insert(mSelectedIndex + 1,
lstQuestions.Items(mOtherIndex))
lstQuestions.Items.RemoveAt(mOtherIndex)
End If

TIA.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top