title: C# Switch Statements and Radio Button Lists
body: <p>I am working a web form and I am having a bit of trouble. I have a radio button list on the page for the user to select an item from. Depending on their selection, I would like for a field to appear on the screen for them to elaborate their request. </p>
  
  <p>Here is my HTML for my radio button list and panels:</p>
  
  <pre><code>&lt;div class="formInformation"&gt;
                      &lt;div class="reason"&gt;
                          &lt;h3&gt;&lt;b&gt;Why are you requesting a new badge?&lt;/b&gt;&lt;/h3&gt;
                          &lt;asp:RadioButtonList ID="rblReason" runat="server" AutoPostBack="true"
                              RepeatDirection="Vertical" Width="350px" 
                              onselectedindexchanged="rblReason_SelectedIndexChanged"&gt;
                              &lt;asp:ListItem Text="Broken"&gt;Broken&lt;/asp:ListItem&gt;
                              &lt;asp:ListItem Text="Faded"&gt;Faded&lt;/asp:ListItem&gt;
                              &lt;asp:ListItem Text="Lost"&gt;Lost&lt;/asp:ListItem&gt;
                              &lt;asp:ListItem Text="NotWork"&gt;Doesn&amp;#39;t Work&lt;/asp:ListItem&gt;
                              &lt;asp:ListItem Text="Name"&gt;Name Change&lt;/asp:ListItem&gt;
                              &lt;asp:ListItem Text="Title"&gt;Title Change&lt;/asp:ListItem&gt;
                              &lt;asp:ListItem Text="Dept"&gt;Dept/Location Change&lt;/asp:ListItem&gt;
                              &lt;asp:ListItem Text="Other"&gt;Other&lt;/asp:ListItem&gt;
                          &lt;/asp:RadioButtonList&gt;
                      &lt;/div&gt;
                      &lt;div class="reason"&gt;
                          &lt;h3&gt;&lt;b&gt;Further Information:&lt;/b&gt;&lt;/h3&gt;
                          &lt;h4&gt;*Fields will become visible depending on your selection to the left*&lt;/h4&gt;
                          &lt;asp:Panel ID="pnlLost" runat="server" Visible="False"&gt; 
                              &lt;div class="pnlText"&gt;&lt;h5&gt;&lt;b&gt;Are you enrolled in QuickCharge?&lt;/b&gt;&lt;/h5&gt;&lt;/div&gt;
                              &lt;asp:RadioButtonList ID="rblLost" runat="server"
                                  RepeatDirection="Horizontal" Width="350px"&gt;
                                  &lt;asp:ListItem&gt;Yes&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem&gt;No&lt;/asp:ListItem&gt;
                              &lt;/asp:RadioButtonList&gt;
                          &lt;/asp:Panel&gt;
                          &lt;asp:Panel ID="pnlDoesNotWork" runat="server" Visible="False"&gt;
                              &lt;div class="pnlText"&gt;&lt;h5&gt;&lt;b&gt;Explain what doesn't work:&lt;/b&gt;&lt;/h5&gt;&lt;/div&gt;
                              &lt;asp:TextBox ID="txtNotWorking" runat="server" TextMode="MultiLine" 
                                      Width="225px"&gt;&lt;/asp:TextBox&gt;
                          &lt;/asp:Panel&gt;
                          &lt;asp:Panel ID="pnlNameChange" runat="server" Visible="False"&gt;
                              &lt;div class="pnlText"&gt;&lt;h5&gt;&lt;b&gt;For name change:&lt;/b&gt;&lt;/h5&gt;&lt;/div&gt;
                              &lt;div class="pnlText"&gt;Submit request then contact HR: 770.836.9517&lt;/div&gt;
                          &lt;/asp:Panel&gt;
                          &lt;asp:Panel ID="pnlTitleChange" runat="server" Visible="False"&gt;
                              &lt;div class="pnlText"&gt;&lt;h5&gt;&lt;b&gt;What is you new title?&lt;/b&gt;&lt;/h5&gt;&lt;/div&gt;
                              &lt;asp:TextBox ID="txtNewTitle" runat="server" TextMode="MultiLine" 
                                      Width="225px"&gt;&lt;/asp:TextBox&gt;
                          &lt;/asp:Panel&gt;
                          &lt;asp:Panel ID="pnlDeptLocation" runat="server" Visible="False"&gt;
                              &lt;div class="pnlText"&gt;&lt;h5&gt;&lt;b&gt;What is your new Dept/Location?&lt;/b&gt;&lt;/h5&gt;&lt;/div&gt;
                              &lt;asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" 
                                      Width="225px"&gt;&lt;/asp:TextBox&gt;
                          &lt;/asp:Panel&gt;
                          &lt;asp:Panel ID="pnlOther" runat="server" Visible="False"&gt;
                              &lt;div class="pnlText"&gt;&lt;h5&gt;&lt;b&gt;Elaborate:&lt;/b&gt;&lt;/h5&gt;&lt;/div&gt;
                              &lt;asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" 
                                      Width="225px"&gt;&lt;/asp:TextBox&gt;
                          &lt;/asp:Panel&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  </code></pre>
  
  <p>Here is my C# to display panels based on selection in the radio button list</p>
  
  <pre><code>  protected void rblReason_SelectedIndexChanged(object sender, EventArgs e)
      {
          switch (rblReason.SelectedItem.Text)
          {
              case "Broken":
                  pnlLost.Visible = false;
                  pnlDoesNotWork.Visible = false;
                  pnlNameChange.Visible = false;
                  pnlTitleChange.Visible = false;
                  pnlDeptLocation.Visible = false;
                  pnlOther.Visible = false;
                  break;
              case "Faded":
                  pnlLost.Visible = false;
                  pnlDoesNotWork.Visible = false;
                  pnlNameChange.Visible = false;
                  pnlTitleChange.Visible = false;
                  pnlDeptLocation.Visible = false;
                  pnlOther.Visible = false;
                  break;
              case "Lost":
                  pnlLost.Visible = true;
                  pnlDoesNotWork.Visible = false;
                  pnlNameChange.Visible = false;
                  pnlTitleChange.Visible = false;
                  pnlDeptLocation.Visible = false;
                  pnlOther.Visible = false;
                  break;
              case "NotWork":
                  pnlDoesNotWork.Visible = true;
                  pnlLost.Visible = false;
                  pnlNameChange.Visible = false;
                  pnlTitleChange.Visible = false;
                  pnlDeptLocation.Visible = false;
                  pnlOther.Visible = false;
                  break;
              case "Name":
                  pnlNameChange.Visible = true;
                  pnlLost.Visible = false;
                  pnlDoesNotWork.Visible = false;
                  pnlTitleChange.Visible = false;
                  pnlDeptLocation.Visible = false;
                  pnlOther.Visible = false;
                  break;
              case "Title":
                  pnlTitleChange.Visible = true;
                  pnlLost.Visible = false;
                  pnlDoesNotWork.Visible = false;
                  pnlNameChange.Visible = false;
                  pnlDeptLocation.Visible = false;
                  pnlOther.Visible = false;
                  break;
              case "Dept":
                  pnlDeptLocation.Visible = true;
                  pnlLost.Visible = false;
                  pnlDoesNotWork.Visible = false;
                  pnlNameChange.Visible = false;
                  pnlTitleChange.Visible = false;
                  pnlOther.Visible = false;
                  break;
              case "Other":
                  pnlOther.Visible = true;
                  pnlLost.Visible = false;
                  pnlDoesNotWork.Visible = false;
                  pnlNameChange.Visible = false;
                  pnlTitleChange.Visible = false;
                  pnlDeptLocation.Visible = false;
                  break;
          }
      }
  </code></pre>
  
  <p>Currently the "Broken", "Faded", "Lost", and "Other" cases work perfectly. Any ideas why the other four don't? I tried looking for spelling errors, but I didn't find any. Then again it could just be that I can't see my own mistakes. </p>
  
  <p>Any assistance is appreciated!</p>