Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 回发时下拉列表恢复为索引_Asp.net_Drop Down Menu - Fatal编程技术网

Asp.net 回发时下拉列表恢复为索引

Asp.net 回发时下拉列表恢复为索引,asp.net,drop-down-menu,Asp.net,Drop Down Menu,所以在这里,我使用asp.net和vb作为我的后台代码。所以这里有一个问题,我动态地将我的所有值级联到另一个下拉列表的值,就像用ajax级联下拉列表一样。但问题是,我的下拉列表中的1将其索引恢复为1,而另一个下拉列表使用其选定的值进行修复 我有一种感觉,这是由于数据绑定的价值观,这个下拉列表 下面是我的html标记和vb代码隐藏 Agency<asp:DropDownList ID="DDLAgency" runat="server" AutoPostBack="true" OnS

所以在这里,我使用asp.net和vb作为我的后台代码。所以这里有一个问题,我动态地将我的所有值级联到另一个下拉列表的值,就像用ajax级联下拉列表一样。但问题是,我的下拉列表中的1将其索引恢复为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 />
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

确保没有在每次回发时调用get\u prod\u version()。i、 e.如果没有Page.IsPostBack,则绑定ddl。实际上,我不会在回发时调用它。。在每次回发中,ddl是否调用get\u prod\r并使用相同的查询变量绑定自身?