当前位置: 代码迷 >> ASP.NET >> dropdownlist在修改时如何加载原来的数据
  详细解决方案

dropdownlist在修改时如何加载原来的数据

热度:5484   发布时间:2013-02-25 00:00:00.0
dropdownlist在修改时怎么加载原来的数据?
二级联动的dropdownlist在修改时怎么加载原来的数据?

DropDownList2.SelectedValue = ds.tables(0).Rows(0)(3).ToString()这样好像读取不到

<asp:Label ID="Label3" runat="server" Text="部門編號"></asp:Label>
 <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" Width="104px">
</asp:DropDownList>

------解决方案--------------------------------------------------------
先绑定datalist的数据
 Private Sub Listdepnum()
If DropDownList1.SelectedIndex <> -1 Then
Dim sql As String = "select depnum from c_dep where fac='" + DropDownList1.SelectedValue + "'"
Dim ds As DataSet = SqlHelper.ExcuteReadApdater(sql, CommandType.Text, Nothing)
DropDownList2.DataSource = ds

DropDownList2.DataTextField = "depnum"
DropDownList2.DataValueField = "depnum"
DropDownList2.DataBind()

DropDownList2.Items.Insert(0, New ListItem("请选择", " "))
End If
End Sub

然后再可以用DropDownList3.SelectedValue = 

 Listdepnumm()
 DropDownList2.SelectedValue = 。。。
  相关解决方案