C# – Mutually exclusive selection of Radiobutton in gridView.ASP.NET C#

asp.netcgridviewradio-button

    <asp:TemplateField HeaderText="Select One">

    <ItemTemplate>
    <asp:RadioButton ID="RadioButton1" runat="server" />

    </ItemTemplate>

    </asp:TemplateField> 

aspx.cs

protected void Button1_Click(object sender, EventArgs e)
{
    foreach (GridViewRow di in GridView1.Rows)
    {
        RadioButton rad = (RadioButton)di.FindControl("RadioButton1");

        if (rad.Checked&&rad!=null)
        {
            s = di.Cells[1].Text;
        }

    }

    Response.Redirect("applicants.aspx?form=" +s);

}

I'm selecting the rows that are selected with this but I have a problem here I want user to be able to select only one radiobutton but its allowing all the radiobuttons to be selected at once.Can you help me in removing this problem please.
please.enter image description here

Best Answer

Maybe I'm too late here on the party but this will do the trick, check out here......

This might be useful for someone watching this answer in the future.

Related Topic