for(i=1;i<=10;i++)
{
RadioButtonList rad = new RadioButtonList();
rad.ID = "rad" + i.ToString();
lbl.Attributes.Add("runat", "Server");
rad.Style.Add(HtmlTextWriterStyle.Position, "absolute");
rad.Style[HtmlTextWriterStyle.Top] = top + 20 + "px";
rad.Style[HtmlTextWriterStyle.Left] = "200px";
rad.Attributes.Add("runat", "Server");
}
例如,我使用名为 rad1 到 rad10 的代码创建 10 个 RadioButtonLists 我想从用户那里获取 rad(1) 到 rad(10).selectedItems ...
rad(i).selectItems
给我一个错误。我想将选定的项目从 rad1 获取到 rad10。例子:
answer1 = rad1.selectItems.tostring();
answer2 = rad2.selectItems.tostring();
answer3 = rad3.selectItems.tostring();
answer4 = rad4.selectItems.tostring();
answer5 = rad5.selectItems.tostring();
answer6 = rad6.selectItems.tostring();
answer7 = rad7.selectItems.tostring();
answer8 = rad8.selectItems.tostring();
answer9 = rad9.selectItems.tostring();
answer10 = rad10.selectItems.tostring();
但我什至不能指定rad1.selecteditems
,它给了我一个错误。它一直说 rad(i) 在上下文中不存在