用Asp做开发,使用c#,Dropdownlist怎样获取选中的值

解决方案 »

  1.   

    <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" 
            onselectedindexchanged="DropDownList2_SelectedIndexChanged">
            <asp:ListItem Value="1">Item 1</asp:ListItem>
            <asp:ListItem Value="2">Item 2</asp:ListItem>
    </asp:DropDownList>protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {
            Literal msg = new Literal();
            msg.Text = "<script>alert('" + ((DropDownList)sender).SelectedValue + "')</script>";
            this.Controls.Add(msg);
    }
      

  2.   

    DropDownList.SelectedValue 和Item .