asp.net radio button grouping

I finally got around this by creating a plain radio button and setting the value using an server-side eval.

<input type="radio" name="radCustomer" value='<%#Eval("CustomerNumber") %>' />

Now when the application performs a postback, I check for the value of Request.Form["radCustomer"]. This works flawlessly.


I fixed it in javascript:

$(function () {
  $("#divWithGridViewOrRepeater input:radio").attr("name", "yourGroupName");
}); 

Unfortunately, this is a well known issue with radio buttons within a repeater. One of your only options would be to create a custom server control derived from the RadioButton class and override how it renders.

EDIT: Here's a sample of what the derived class may look like:

public class MyRadioButton : RadioButton
{
    protected override void Render(HtmlTextWriter writer)
    {
        writer.Write("<input id=\"" + base.ClientID + "\" ");
        writer.Write("type=\"radio\" ");
        writer.Write("name=\"" + base.ID + "\" ");
        writer.Write("value=\"" + base.ID + "\" />");
        writer.Write("<label for=\"" + base.ClientID + "\">");
        writer.Write(base.Text);
        writer.Write("</label>");
    }
}