前台用了repeater控件,repeater里装着<asp:RadioButton ID="rdbUserName" runat="server" AutoPostBack="true" ValidationGroup='<%#Eval("U_UserID") %>' OnCheckedChanged="RadioButton_CheckedChanged"/>
后台:
public void RadioButton_CheckedChanged(object sender, EventArgs e)
{ RadioButton rdb = sender as RadioButton;
RepeaterItem item = rdb.Parent as RepeaterItem;
int count = rptItems.Items.Count;
for (int i = 0; i < count; i++)
{
RadioButton rdbUserName = rptItems.Items[i].FindControl("rdbUserName") as RadioButton;
userId = rdb.ValidationGroup.ToString();
if (i != item.ItemIndex)
{
rdbUserName.Checked = false;
}
}
}