title: how do i get the selected radiobutton value in asp.net
body: <p>this is my code to know, which radio-button has been selected, but getting error at line 6. <code>Object reference not set to an instance of an object</code></p>
  
  <pre><code>Dim selected_option As String = "0"
          For i = 1 To 4
              Dim rdbName As String = "rb_option" &amp; i
              Dim rdb As New RadioButton()
              rdb = CType(Me.Page.FindControl(rdbName), RadioButton)
              If rdb.Checked = True Then
                  selected_option = i.ToString
                  Exit For
              End If
          Next
  </code></pre>
  
  <p>There are 4 radio-button with ID <code>rb_option1</code>,<code>rb_option2</code>,<code>rb_option3</code> and <code>rb_option4</code>.</p>
  
  <p><strong>Update</strong></p>
  
  <pre><code>&lt;asp:Repeater ID="Repeater1" runat="server"&gt;
    &lt;HeaderTemplate&gt;
    &lt;table style="width: 100%; height: 100%; margin-bottom: 50px"&gt;
    &lt;/HeaderTemplate&gt;
    &lt;ItemTemplate&gt;
    &lt;tr&gt;
    &lt;td style="width: 95%"&gt;
    &lt;asp:Label ID="lbl_question" CssClass="frm_label" Text='&lt;%# Eval("QUESTION")%&gt;'runat="server"&gt;&lt;/asp:Label&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt;
    &lt;asp:RadioButton ID="rb_option1" Checked='&lt;%# IF(Eval("ANSWER")="1",true,false) %&gt;' GroupName="answer" Text='&lt;%# Eval("OPT1") %&gt;' CssClass="frm_label" runat="server" /&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt;
    &lt;asp:RadioButton ID="rb_option2" Checked='&lt;%# IF(Eval("ANSWER")="2",true,false) %&gt;' GroupName="answer" Text='&lt;%# Eval("OPT2") %&gt;' CssClass="frm_label" runat="server" /&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt;
    &lt;asp:RadioButton ID="rb_option3" Checked='&lt;%# IF(Eval("ANSWER")="3",true,false) %&gt;' GroupName="answer" Text='&lt;%# Eval("OPT3") %&gt;' CssClass="frm_label" runat="server" /&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt;
    &lt;asp:RadioButton ID="rb_option4" Checked='&lt;%# IF(Eval("ANSWER")="4",true,false) %&gt;' GroupName="answer" Text='&lt;%# Eval("OPT4") %&gt;' CssClass="frm_label" runat="server" /&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;/ItemTemplate&gt;
    &lt;FooterTemplate&gt;
    &lt;/table&gt;
    &lt;/FooterTemplate&gt;
    &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>Thank in advance !!</p>