2013-05-21 38 views
-2

在我的asp.net应用程序中,我有两个dropdownlist,如果我选择第一个的一个值,意味着自动想要更改下拉两个值,但它不工作。这里是我的asp代码。我如何使用ASP.NET更新面板?

<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> 
+3

什么不起作用。请解释这个问题。另外,发布帖子后面的代码会很有用。 – webnoob

+0

将您的代码发布到'DropDownList1_SelectedIndexChanged' – Emre

回答

1

我复制你的代码,因为它是,并且给了定义选择的指数变化情况作为

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

,它精美的工作。你可能有其他问题。你可以复制你选择的索引更改的事件代码吗?