Asp.net 在vb.net中更改DropDownList中项目的顺序

Asp.net 在vb.net中更改DropDownList中项目的顺序,asp.net,vb.net,Asp.net,Vb.net,我已经用从1到10的数值(项目)填充了DropDownList。这些项目按顺序出现。现在我想洗牌这些项目 类似项目1出现在第8位 第2项出现在第6位等 我知道我可以用交换方法来做,但是 有没有更有效的方法呢?我不知道下拉列表,所以我为列表框写了一些代码 ' Up Dim Index As Integer = ListBox1.SelectedIndex If Index > 0 Then Dim Value As String = ListBox1.SelectedItem

我已经用从1到10的数值(项目)填充了DropDownList。这些项目按顺序出现。现在我想洗牌这些项目 类似项目1出现在第8位 第2项出现在第6位等 我知道我可以用交换方法来做,但是
有没有更有效的方法呢?

我不知道
下拉列表
,所以我为
列表框
写了一些代码

' Up
Dim Index As Integer = ListBox1.SelectedIndex
If Index > 0 Then
    Dim Value As String = ListBox1.SelectedItem
    ListBox1.Items.RemoveAt(Index)
    ListBox1.Items.Insert(Index - 1, Value)
Else
    ' Cannot move up the first item or no item selected
End If

' Down
Dim Index As Integer = ListBox1.SelectedIndex
If Index > -1 And Index < ListBox1.Items.Count - 1 Then
    Dim Value As String = ListBox1.SelectedItem
    ListBox1.Items.RemoveAt(Index)
    ListBox1.Items.Insert(Index + 1, Value)
Else
    ' Cannot move down the last item or no item selected
End If
”向上
将索引设置为整数=ListBox1.SelectedIndex
如果索引>0,则
Dim值为String=ListBox1.SelectedItem
ListBox1.Items.RemoveAt(索引)
ListBox1.Items.Insert(索引-1,值)
其他的
'无法向上移动第一个项目或未选择任何项目
如果结束
“下来
将索引设置为整数=ListBox1.SelectedIndex
如果索引>-1且索引
显示一些代码,交换似乎非常有效。对于i As UShort=0到10个随机问题编号。Items.Add(i.ToString())next,我想知道是否有内置的方法可以更改dropdownlist中项目的顺序?能否将它们按您想要的顺序放置并绑定到数据列表?