我正在使用下面的代码在选择的另一个下拉列表中填充下拉列表。但不知何故,当在 ddlTypes 中选择一个项目时,不会填充 ddlSubTypes
在 ddlTypes 的 selectedindex 更改事件上,我正在绑定 ddlSubTypes。
<tr>
<td class="style3">
<asp:ScriptManager ID="scma" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UP1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlTypes" runat="server" Width="200px" AutoPostBack="true" OnSelectedIndexChanged="ddlTypes_SelectedIndexChanged1">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td class="style3">
<asp:UpdatePanel ID="UP2" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlSubTypes" runat="server" Width="200px">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
Protected Sub ddlTypes_SelectedIndexChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlTypes.SelectedIndexChanged
Try
'Populate schemes
ddlSubTypes.Items.Clear()
Dim ID As Integer = ddlTypes.SelectedValue
Dim dt As DataTable = IterateSubtypesContents(ID)
ddlSubTypes.DataTextField = dt.Columns("Type").ToString()
ddlSubTypes.DataValueField = dt.Columns("ID").ToString()
ddlSubTypes.DataSource = dt
ddlSubTypes.DataBind()
UP2.Update()
Catch ex As Exception
End Try
End Sub