所以在这里,我使用asp.net和vb作为我的代码。所以这里是catch,我将所有值相应地动态级联到另一个下拉列表的值,就像ajax的级联下拉一样。但问题是我的下拉列表中的一个是将其索引恢复为1而另一个下拉列表是使用所选值修复的。
我感觉这是由于数值绑定到此下拉菜单引起的。
下面是我的html标记和vb代码隐藏 Agency<asp:DropDownList ID="DDLAgency" runat="server" AutoPostBack="true" OnSelectedIndexChanged="agen_choose" >
<asp:ListItem Text="Agency"></asp:ListItem>
</asp:DropDownList>
<br />
Advertiser<asp:DropDownList ID="DDLAdvert" runat="server" AutoPostBack="true" OnSelectedIndexChanged = "adver_choose" >
<asp:ListItem Text="Advertiser" ></asp:ListItem>
</asp:DropDownList>
<br />
Product <asp:DropDownList ID="DDLProd" runat="server" AutoPostBack="true" OnSelectedIndexChanged="get_prod_version" OnDataBinding="lem">
<asp:ListItem Text="Product"></asp:ListItem>
</asp:DropDownList>
<br />
Version and Length <asp:DropDownList ID="DDlVer" runat="server">
<asp:ListItem Text="Version"></asp:ListItem>
</asp:DropDownList>
<br />
Program <asp:DropDownList ID="DDLProg" runat="server" >
<asp:ListItem Text="Program"></asp:ListItem> </asp:DropDownList>
<br />
这是vb codebehind
Protected Sub get_prod_version()
Dim conn As New SqlConnection(Session("cs").ToString)
Select Case Session("platform").ToString
Case "A"
Dim que1 As String = "select v_version +' Lenght:' + convert(varchar(10), v_spotlen) as 'Version And Lenght', v_vpcode from tb.tbl where v_vpcode = (select p_pcode from sysadm.product where p_pcode='" & DDLProd.SelectedValue & "')"
Dim cmd4 As New SqlCommand(que1, conn)
conn.Open()
DDlVer.DataSource = cmd4.ExecuteReader
DDlVer.DataTextField = "Version And Lenght"
DDlVer.DataValueField = "v_vpcode"
DDlVer.DataBind()
conn.Close()
DDlVer.Items.Add("Version")
'--
Case "B"
Dim que1 As String = "select v_version +' Lenght:' + convert(varchar(10), v_spotlen) as 'Version And Lenght', v_vpcode from tb.tbl where v_vpcode = (select p_pcode from sysadm.product where p_pcode='" & DDLProd.SelectedValue & "')"
Dim cmd4 As New SqlCommand(que1, conn)
conn.Open()
DDlVer.DataSource = cmd4.ExecuteReader
DDlVer.DataTextField = "Version And Lenght"
DDlVer.DataValueField = "v_vpcode"
DDlVer.DataBind()
conn.Close()
DDlVer.Items.Add("Version")
'--
Case "C"
Dim que1 As String = "select v_version +' Lenght:' + convert(varchar(10), v_spotlen) as 'Version And Lenght', v_vpcode from tb.tbl where v_vpcode = (select p_pcode from QTVSA.product where p_pcode='" & DDLProd.SelectedValue & "')"
Dim cmd4 As New SqlCommand(que1, conn)
conn.Open()
DDlVer.DataSource = cmd4.ExecuteReader
DDlVer.DataTextField = "Version And Lenght"
DDlVer.DataValueField = "v_vpcode"
DDlVer.DataBind()
conn.Close()
'--
DDlVer.Items.Add("Version")
Case "D"
Dim que1 As String = "select v_version +' Lenght:' + convert(varchar(10), v_spotlen) as 'Version And Lenght', v_vpcode from tb.tbl where v_vpcode = (select p_pcode from SYSADM.product where p_pcode='" & DDLProd.SelectedValue & "')"
Dim cmd4 As New SqlCommand(que1, conn)
conn.Open()
DDlVer.DataSource = cmd4.ExecuteReader
DDlVer.DataTextField = "Version And Lenght"
DDlVer.DataValueField = "v_vpcode"
DDlVer.DataBind()
conn.Close()
'--
DDlVer.Items.Add("Version")
Case "E"
Dim que11 As String = "select v_version +' Lenght:' + convert(varchar(10), v_spotlen) as 'Version And Lenght', v_vpcode from tb.tbl where v_vpcode = (select p_pcode from QTVSA.product where p_pcode='" & DDLProd.SelectedValue & "')"
Dim cmd41 As New SqlCommand(que11, conn)
conn.Open()
DDlVer.DataSource = cmd41.ExecuteReader
DDlVer.DataTextField = "Version And Lenght"
DDlVer.DataValueField = "v_vpcode"
DDlVer.DataBind()
conn.Close()
'--
DDlVer.Items.Add("Version")
End Select
End Sub