title: Display the selected item of a RadioButtonList in TextBox
body: <p>I am new to ASP.NET. I am trying to display the text of a radio button in a text box when the radio button is selected. I have tried two different ways of doing it without success:</p>
  
  <p>Attempt 1:</p>
  
  <p>Code in my aspx file:</p>
  
  <pre><code>&lt;asp:RadioButtonList ID="radioList" runat="server"&gt;
  &lt;asp:ListItem Value="selection1" Text ="One"&gt;&lt;/asp:ListItem&gt;
  &lt;asp:ListItem Value="selection2" Text="Two"&gt;&lt;/asp:ListItem&gt;
  &lt;/asp:RadioButtonList&gt;
  </code></pre>
  
  <p>And then my .cs code:</p>
  
  <pre><code>public void displayText(object sender, EventArgs e)
  {
      var result = radioList.SelectedValue;
      output.Text = result.Text; /* Have also tried result.ToString() */
  }
  </code></pre>
  
  <p>Attempt 2:</p>
  
  <p>Same aspx as above</p>
  
  <p>.cs code:</p>
  
  <pre><code>public void displayText(object sender, EventArgs e)
  {
      if (selection1.Checked)
      {
          output.Text = "One";
      }
  }
  </code></pre>
  
  <p>The first attempt doesn't give me any errors, but doesn't display the text. The second attempt gives me Error CS0103 The name 'selection1' does not exist in the current context    1_ASPTEST.aspx</p>
  
  <p>I'm sure it's something simple that I'm just overlooking but I'm stumped. Thanks!</p>