我没有使用面板控件获取下拉列表值相关表单

时间:2015-06-08 13:20:11

标签: asp.net

获取下拉列表作为输出后,在下拉列表中选择用户时,我没有获得相关表单?检查code.i使用面板控件3个用户详细信息表  protected void Page_Load(object sender,Eventargs e)         {

        if (!IsPostBack)
        {
            AdminPanel.Visible = false;
            TeacherPanel.Visible = false;
            StudentPanel.Visible = false;
        }
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedValue == "-1")
        {
            AdminPanel.Visible = false;
            TeacherPanel.Visible = false;
            StudentPanel.Visible = false;
        }
        else if (DropDownList1.SelectedValue == "admin")
        {
            AdminPanel.Visible = true;
            TeacherPanel.Visible = false;
            StudentPanel.Visible = false;
        }
        else if (DropDownList1.SelectedValue == "teacher")
        {
            AdminPanel.Visible = false;
            TeacherPanel.Visible = true;
            StudentPanel.Visible = false;
        }
        else
        {
            AdminPanel.Visible = false;
            TeacherPanel.Visible = false;
            StudentPanel.Visible = true;
        }
    }

1 个答案:

答案 0 :(得分:0)

你的问题没有提供足够的信息,但让我一起摇摆,因为这是人们对DropDownList的常见错误。

如果要在选择DropDownList后将表单发回服务器,则需要设置AutoPostBack="True"

<asp:DropDownList 
    ID="DropDownList1" 
    runat="server"
    AutoPostBack="True"
    OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>