0
votes

after getting drop down list as output, while selecting the users in drop down list i'm not getting related forms? review the code.i used panel control for 3 user detail tables 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
I have no idea what you're asking. Can you describe the problem a bit more? When you debug this, where/how specifically does it fail? - David

1 Answers

0
votes

Your question did not provide enough information, but let me take a swing, because it is the common mistake people make regarding DropDownList.

If you want to post back the form to server after selecting the DropDownList, you need to set AutoPostBack="True".

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