Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>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</p> <p>EDIT:</p> <p>Something like this should suit your purposes..</p> <pre><code>&lt;asp:Repeater runat="server"&gt; &lt;ItemTemplate&gt; &lt;label&gt;&lt;input type="radio" name="rbEmail" value='&lt;%# ((Action)Container.DataItem).ID %&gt;' /&gt;&lt;%# ((Action)Container.DataItem).Action %&gt;&lt;/label&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p>Then in the postback, you can get the value from Request.Form["rbEmail"]</p> <p>EDIT2:</p> <p>Fully tested simple page example..</p> <p>Default.aspx</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;Untitled Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;asp:Repeater ID="Repeater1" runat="server"&gt; &lt;ItemTemplate&gt; &lt;label&gt;&lt;input type="radio" name="rbEmail" value='&lt;%# Container.DataItem %&gt;' /&gt;&lt;%# Container.DataItem %&gt;&lt;/label&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;asp:Button ID="submit" runat="server" OnClick="submit_Click" Text="submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Default.aspx.cs</p> <pre><code>using System; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Repeater1.DataSource = new string[] { "Hello", "World" }; Repeater1.DataBind(); } protected void submit_Click(object sender, EventArgs e) { Response.Write(Request.Form["rbEmail"]); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload