title: C# ASP.Net - How to Display TextBox Based on Selected Value in DropDownList
body: <p>I am trying to display certain textbox based on the selected value in Dropdownlist. For some reason, it is not working - when a particular item is selected in dropdownlist, none of the inputbox is visible on the page. Hoping to get feedback. Thanks in advance.</p>
  
  <p>Here is the relevant code: </p>
  
  <p>aspx page: </p>
  
  <pre><code>&lt;asp:DropDownList ID="AreaDropDownList" runat="server" OnSelectedIndexChanged="AreaDropDownList_SelectedIndexChanged" AutoPostBack="True"&gt;
              &lt;asp:ListItem&gt;&lt;/asp:ListItem&gt;
              &lt;asp:ListItem&gt;Rectangle&lt;/asp:ListItem&gt;
              &lt;asp:ListItem&gt;Triangle&lt;/asp:ListItem&gt;
              &lt;asp:ListItem&gt;Trapezoid&lt;/asp:ListItem&gt;
              &lt;asp:ListItem&gt;Circle&lt;/asp:ListItem&gt;
              &lt;asp:ListItem&gt;Sector Of Circle&lt;/asp:ListItem&gt;
              &lt;asp:ListItem&gt;Ellipse&lt;/asp:ListItem&gt;
          &lt;/asp:DropDownList&gt;
  
         &lt;asp:TextBox ID="InputTextBox1" runat="server" AutoPostBack="True" Visible="TRUE"&gt;&lt;/asp:TextBox&gt;
         &lt;asp:TextBox ID="InputTextBox2" runat="server" AutoPostBack="True" Visible="TRUE"&gt;&lt;/asp:TextBox&gt;
         &lt;asp:TextBox ID="InputTextBox3" runat="server" AutoPostBack="True" Visible="TRUE"&gt;&lt;/asp:TextBox&gt;
  </code></pre>
  
  <p>aspx.cs page: </p>
  
  <pre><code>protected void AreaDropDownList_SelectedIndexChanged(object sender, EventArgs e)
          {
              if (AreaDropDownList.SelectedValue == "")
              {
                  InputTextBox1.Visible = false;
                  InputTextBox2.Visible = false;
                  InputTextBox3.Visible = false;
              }
  
              else if (AreaDropDownList.SelectedValue == "Rectangle")
              {
                  InputTextBox1.Visible = true;
                  InputTextBox2.Visible = true;
                  InputTextBox3.Visible = false;
              }
  
              else if (AreaDropDownList.SelectedValue == "Triangle")
              {
                  InputTextBox1.Visible = true;
                  InputTextBox2.Visible = true;
                  InputTextBox3.Visible = false;
              }
  
              else if (AreaDropDownList.SelectedValue == "Trapezoid")
              {
                  InputTextBox1.Visible = true;
                  InputTextBox2.Visible = true;
                  InputTextBox3.Visible = true;
              }
  
              else if (AreaDropDownList.SelectedValue == "Circle")
              {
                  InputTextBox1.Visible = true;
                  InputTextBox2.Visible = false;
                  InputTextBox3.Visible = false;
              }
  
              else if (AreaDropDownList.SelectedValue == "Sector")
              {
                  InputTextBox1.Visible = true;
                  InputTextBox2.Visible = true;
                  InputTextBox3.Visible = false;
              }
  
              else if (AreaDropDownList.SelectedValue == "Ellipse")
              {
                  InputTextBox1.Visible = true;
                  InputTextBox2.Visible = true;
                  InputTextBox3.Visible = false;
              }
       }
  </code></pre>