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.
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.