我可以获取此单选按钮的文本和其他属性,但是对于已检查的属性,它将始终返回false
<asp:DataList ID="DataList1" runat="server" Width="904px">
<ItemTemplate>
<table style="width: 100%;" border="1">
<tr>
<td>
<asp:RadioButton ID="option1" runat="server" GroupName="Options" Text="A" />
<%# DataBinder.GetPropertyValue(Container.DataItem, "op1") %>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
C#代码:
protected void Button1_Click(object sender, EventArgs e)
{
int counter = 0;
foreach (DataListItem item in DataList1.Items)
{
RadioButton rb1 = (RadioButton)item.FindControl("option1");
if (rb1.Checked)
{
counter++;
}
}
Response.Write(counter);
}