Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.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_C# 4.0 - Fatal编程技术网

如何使用ASP.NET更新面板?

如何使用ASP.NET更新面板?,asp.net,c#-4.0,Asp.net,C# 4.0,在我的asp.net应用程序中,我有两个dropdownlist,如果我选择第一个dropdownlist,则表示自动想要更改dropdownlist的值,但它不起作用。这是我的asp代码 <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server">

在我的asp.net应用程序中,我有两个dropdownlist,如果我选择第一个dropdownlist,则表示自动想要更改dropdownlist的值,但它不起作用。这是我的asp代码

<asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Label ID="Label1" runat="server" Text="State"></asp:Label>&nbsp;&nbsp;&nbsp;
            <asp:DropDownList ID="ddlState" runat="server" Height="23px" Width="195px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
                AutoPostBack="True">
                <asp:ListItem>--Select--</asp:ListItem>
                <asp:ListItem>Kerela</asp:ListItem>
                <asp:ListItem>Tamilnadu</asp:ListItem>
                <asp:ListItem>Karnataka</asp:ListItem>
            </asp:DropDownList>
            <br />
            <br />
            <br />
            <br />
            <asp:Label ID="Label2" runat="server" Text="District"></asp:Label>&nbsp;&nbsp;&nbsp;
            <asp:DropDownList ID="ddlDistrict" runat="server" Height="23px" Width="189px" AutoPostBack="True">
            </asp:DropDownList>
        </ContentTemplate>
    </asp:UpdatePanel>

--挑选--
喀拉拉
泰米尔纳德邦
卡纳塔克邦





我复制了您的代码,并将选定的索引更改事件定义为

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{ 
     ListItem li = new ListItem("text");
     ddlDistrict.Items.Add(li);
}   

它工作得很好。你可能还有其他问题。您能复制所选的索引更改事件代码吗?

什么不起作用。请解释一下这个问题。此外,发布回发代码也很有用。请在
DropDownList1\u SelectedIndexChanged