title: Event handlers for controls in an ASP Repeater
body: <p>I need to be able to trigger events when a user clicks on a radio button that is generated within an  control on my page.</p>
  
  <p>I've added an <code>OnSelectedIndexChanged</code> handler to the RadioButtonList and created a function in my code behind that should handle the selection of the RadioButtonList's ListItems, but I don't know how to pass a value to that function.
  Here's my code:</p>
  
  <pre><code>&lt;asp:Repeater runat="server" ID="rptQuestions"&gt;
      &lt;HeaderTemplate&gt;&lt;table width="100%"&gt;&lt;/HeaderTemplate&gt;
      &lt;ItemTemplate&gt;
          &lt;tr&gt;
              &lt;td colspan="2"&gt;&lt;%# Container.DataItem("QuestionText")%&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;asp:RadioButtonList runat="server" ID="rblAnswerSelection" RepeatDirection="Horizontal" AutoPostBack="true" OnSelectedIndexChanged="CheckAnswer"&gt;
                      &lt;asp:ListItem Text="True" Value="1"&gt;&lt;/asp:ListItem&gt;
                      &lt;asp:ListItem Text="False" Value="0"&gt;&lt;/asp:ListItem&gt;
                  &lt;/asp:RadioButtonList&gt;
                  &lt;asp:Label runat="server" ID="lblCorrectAnswer" Text="&lt;%#Container.DataItem("CorrectAnswer") %&gt;"&gt;&lt;/asp:Label&gt;
              &lt;/td&gt;
              &lt;td&gt;&lt;asp:Label runat="server" ID="lblResult"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/ItemTemplate&gt;
      &lt;FooterTemplate&gt;&lt;/table&gt;&lt;/FooterTemplate&gt;
  &lt;/asp:Repeater&gt;
  
  Private Function CheckAnswer(ByVal SelectedAnswer As Integer) As Boolean
      Select Case SelectedAnswer
          Case 1 ' User answered True
              If lblCorrectAnswer.Text = "True" Then
                  Return True
              Else
                  Return False
              End If
          Case 0 ' User answered False
              If lblCorrectAnswer.Text = "False" Then
                  Return True
              Else
                  Return False
              End If
      End Select
  End Function
  </code></pre>
  
  <p>The idea is that the user is to be informed whether or not their selected answer was correct. The value of the <code>CheckAnswer</code> function would determine a "CORRECT" or "INCORRECT" message displaying on <code>lblResult</code>. If there's a way to do this without a PostBack, then that would be ideal.</p>
  
  <p>Any suggestions will be greatly appreciated.</p>