title: ASP.NET Get value from Radiobuttonlist
body: <p>I have the following radionbuttonlist in the ASPX:</p>
  
  <pre><code>Line 62:    &lt;td class="auto-style6"&gt;2 Gender&lt;/td&gt;
  Line 63:    &lt;td&gt;
  Line 64:    &lt;asp:RadioButtonList ID="rblGender" runat="server" RepeatDirection="Horizontal" OnSelectedIndexChanged="rblGender_SelectedIndexChanged"&gt;
  Line 65:        &lt;asp:ListItem Value="Male"&gt;Male&lt;/asp:ListItem&gt;
  Line 66:            &lt;asp:ListItem Value="Female"&gt;Female&lt;/asp:ListItem&gt;
  Line 67:        &lt;/asp:RadioButtonList&gt;
  Line 68:    &lt;/td&gt;
  </code></pre>
  
  <p>I am trying to get the selected value of a checked radio button (Male/Female) and display it in a textfield when I click a button.</p>
  
  <p>I thought it should be something really easy, and I have the following code in c#.</p>
  
  <pre><code>protected void btnTest_Click(object sender, EventArgs e)
  {
      txtGender.Text = rblGender.SelectedValue;
  }
  </code></pre>
  
  <p>Everything can compile without any errors. However when I run the web form in the browser and click the <code>btnTest</code>, the browser shows the following error:
  It also highlighted the above code snippet at <strong>line 64</strong> in red.</p>
  
  <blockquote>
    <p><strong>Compiler Error Message</strong>: CS1061: 'ASP.userForm_aspx' does not contain a definition for 'rblGender_SelectedIndexChanged' and no extension method 'rblGender_SelectedIndexChanged' accepting a first argument of type 'ASP.userForm_aspx' could be found (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p><strong>Question</strong>: What did I missed out or done wrongly? </p>
  
  <p><em>There are other questions with this topic in SO, however theirs could be easily fixed using <code>.selectedValue</code>. When I tried mine, it gives me the above error.</em></p>