Page_Load 里动态生成RadioButtonList,如果在另一方法中调用(本人调用提示不存在)
在Page_Load方法里
RadioButtonList objRadioButtonList = new RadioButtonList();
VoteArray为从别处取到值的一个数组
for (int i = 0; i < VoteArray.Length; i++)
{
objRadioButtonList.Items.Add(VoteArray[i]);
//InAll = InAll + Convert.ToInt32(votenum[i]);
}
objRadioButtonList.ID = "radio1";
PlaceHolder1.Controls.Add(objRadioButtonList);
在一个按钮的单击事件里buttonsend_click
for (int j = 0; j < VoteArray.Length; j++)
{
if (radio1.SelectedIndex== VoteArray[j])
{
VotenumArray[j] = Convert.ToString(Convert.ToInt32(VotenumArray[j]) + 1);
}
}
提示“当前上下文不存在‘radio1’”
弄了好几个小时了,请前辈赐教,在线等,谢谢