我能够获取此单选按钮的文本和其他属性,但它总是会返回 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);
}