我以这种方式创建了一系列单选按钮:
RadioButton[] radio = new RadioButton[size];
for (int i = 0; i < size ; i++)
{
radio[i] = new RadioButton();
radio[i].ID = "voted"+i.ToString();
radio[i].GroupName = "voted";
Session[radio[i].ID] = radio[i];
}
当用户单击按钮时,事件是
protected void Votes_Click(object sender, EventArgs e)
{
RadioButton r=new RadioButton();
for (int i = 0; i < (int)Session["cancount"]; i++)
{
r=(RadioButton)(Session["voted" + i.ToString()]);
if (r.Checked)
{
//Do somethings;
}
}
}
但是的价值r.checked
总是false
,为什么它没有改变?