title: Allowing only one radio button to be checked in each row of grid view
body: <p>Hi guys i used a grid view to insert multiple rows of record into the database . this is how my grid view looks like <img src="https://i.stack.imgur.com/752HG.jpg" alt="enter image description here"></p>
  
  <p>The problem is that all radio buttons can be selected , i need only 1 radio button to be selected for each row .. . My web form works in the way where user have to select the correct answer out of the two textboxes with a radio button then i will have to submit the checked answer to database . is this possible?</p>
  
  <p>aspx : ` 
          
                
                      </p>
  
  <pre><code>             &lt;asp:ButtonField Text="SingleClick" CommandName="SingleClick"
                      Visible="False" /&gt;
  
                      &lt;asp:TemplateField HeaderText="Question"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;br /&gt;
                              &lt;asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"&gt;&lt;/asp:TextBox&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
                      &lt;asp:TemplateField HeaderText="Answer"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;br /&gt;
                              &lt;asp:TextBox ID="TextBox2" runat="server"&gt;&lt;/asp:TextBox&gt;
                              &lt;asp:RadioButton ID="RadioButton1" runat="server" /&gt;
                              &lt;br /&gt;
                              &lt;asp:TextBox ID="TextBox3" runat="server"&gt;&lt;/asp:TextBox&gt;
                              &lt;asp:RadioButton ID="RadioButton2" runat="server" /&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
                      &lt;asp:TemplateField ShowHeader="False"&gt;
                          &lt;FooterTemplate&gt;
                              &lt;asp:Button ID="btnAdd" runat="server" Text="+" onclick="btnAdd_Click1" /&gt;
                          &lt;/FooterTemplate&gt;
  
                      &lt;/asp:TemplateField&gt;
                  &lt;/Columns&gt;
              &lt;/asp:GridView&gt;
      &lt;/td&gt;
  &lt;/tr&gt;`
  </code></pre>
  
  <p>code behind : </p>
  
  <pre><code>  protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
      {
          //Clear the existing selected row 
          foreach (GridViewRow oldrow in GridView1.Rows)
          {
              ((RadioButton)oldrow.FindControl("RadioButton1")).Checked = false;
          }
  
          //Set the new selected row
          RadioButton rb = (RadioButton)sender;
          GridViewRow row = (GridViewRow)rb.NamingContainer;
          ((RadioButton)row.FindControl("RadioButton1")).Checked = true;
  
      }
  </code></pre>