This is so damn stupid but driving me absolutely fing crazy.
<input type="radio" name="OptGroup" id="<%#"rbEmail" + ((Action)Container.DataItem).ID %>" value="<%#((Action)Container.DataItem).ID %>" runat="server" /><label for="<%#"rbEmail" + ((Action)Container.DataItem).ID %>"><%#((Action)Container.DataItem).Action %></label>
What am I doing wrong here! I’ve also tried:
<input type="radio" name="OptGroup" id='<%#"rbEmail" + ((Action)Container.DataItem).ID %>' value='<%#((Action)Container.DataItem).ID %>' runat="server" /><label for='<%#"rbEmail" + ((Action)Container.DataItem).ID %>'><%#((Action)Container.DataItem).Action %></label>
and
<input type="radio" name="OptGroup" id="<%#'rbEmail' + ((Action)Container.DataItem).ID %>" value="<%#((Action)Container.DataItem).ID %>" runat="server" /><label for="<%#'rbEmail' + ((Action)Container.DataItem).ID %>"><%#((Action)Container.DataItem).Action %></label>
I specifically do not want to use an asp.net radiobutton due to the problems with GroupName it creates while inside a repeater. I want to use a bare radio button and bind its values to my datasource.
Do you need to access the control server-side? If not, take off the runat=”server”, you cannot databind to the ID property for a server control. Not sure if thats the problem, since that should give you a different error
EDIT:
Something like this should suit your purposes..
Then in the postback, you can get the value from Request.Form[“rbEmail”]
EDIT2:
Fully tested simple page example..
Default.aspx
Default.aspx.cs