通过点击“添加”,动态添加到RadioButtonList 中
protected void Button1_Click(object sender, EventArgs e)
{
rdbAnswers.Items.Add(new ListItem(txtAnswer.Text, ""));
}
但删除时总获取不到选中项,不管多少项都是获取的第一项。
protected void Button2_Click(object sender, EventArgs e)
{
rdbAnswers.Items.Remove(rdbAnswers.SelectedItem);
}
protected void Button1_Click(object sender, EventArgs e)
{
//rdbAnswers.Items.Add(new ListItem(txtAnswer.Text,""));
rdbAnswers.Items.Add(new ListItem(txtAnswer.Text, txtAnswer.Text));
}
protected void Button2_Click(object sender, EventArgs e)
{
rdbAnswers.Items.Remove(rdbAnswers.SelectedItem);
}
试了下这样是可以的,原因可能是ListItem的Value值不能为空!