title: Changing panel visibility property on radiobuttonlist selection in asp.net page
body: <p>Good morning stackoverflow!</p>
  
  <p>I have a little problem I'm trying to work out thats bugging the life out of me!</p>
  
  <p>On my .aspx page i want to be able to show and hide certain panels depending on user selections (radiobuttonlists). </p>
  
  <p>For example in my aspx page i have;</p>
  
  <pre><code>&lt;form id="form1" runat="server"&gt;
      &lt;asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True"&gt;
          &lt;asp:ListItem&gt;1&lt;/asp:ListItem&gt;
          &lt;asp:ListItem&gt;2&lt;/asp:ListItem&gt;
          &lt;asp:ListItem&gt;3&lt;/asp:ListItem&gt;
      &lt;/asp:RadioButtonList&gt;
  
      &lt;asp:Panel ID="Panel1" runat="server" Width="50%"&gt;
          Visible or not visible depending on radio choice&lt;br /&gt;
          &lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
      &lt;/asp:Panel&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>Then in my aspx.vb i have;</p>
  
  <pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          If RadioButtonList1.SelectedItem.Equals(Nothing) Then
              Panel1.Visible = False
          Else
              RadioButtonList1.SelectedItem.Equals(3)
              Panel1.Visible = True
          End If
  
      End Sub
  </code></pre>
  
  <p>I've also tried a few different variants of this code, along with trying a select statement. If anyone could offer any advise on how to work this one out it greatly appreciate it</p>
  
  <p>Thanks a lot,
  Phil</p>
  
  <p>EDIT:</p>
  
  <p>After further attempts and some reading on msdn I now have;</p>
  
  <pre><code> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
  
  
  ' Show or Hide the Panel contents.
      If RadioButtonList1.SelectedItem.Equals(3) Then
          Panel1.Visible = True
      Else
          Panel1.Visible = False
      End If
  
  End Sub
  </code></pre>
  
  <p>But when I try to run the code I get; </p>
  
  <p>"Object reference not set to an instance of an object" on this line If RadioButtonList1.SelectedItem.Equals(3) Then</p>