我在运行时将 HTML 通用控件创建为 (ul) 和 (il)。然后我想在我的页面内循环以在运行时创建所有 ul 和 il ,但是当我单击按钮时,我创建的所有控件都消失了。如何将其保存在我的页面中以循环访问它?
protected void AddHtmlGroups( int groups,ArrayList judids ,int judnum)
{
for (int i = 1; i <= groups; i++)
{
HtmlGenericControl myUnOrderedList = new HtmlGenericControl("ul");
HtmlGenericControl fieldset = new HtmlGenericControl("fieldset ");
HtmlGenericControl legend = new HtmlGenericControl("legend ");
legend.InnerText="المجموعه " + i.ToString();
legend.Attributes.Add("class", "group");
myUnOrderedList.Controls.Add(legend);
myUnOrderedList.ID = i.ToString()+"g";
myUnOrderedList.Attributes.Add("class", "profList column");
for (int j = 1; j <= judnum; j++)
{
if (judids.Count > 0)
{
HtmlGenericControl listItem = new HtmlGenericControl("li");
listItem.ID = judids[0].ToString();
string judname = getjudgeName(Convert.ToInt32(judids[0]));
if (judname != null)
{
listItem.InnerText = judname;
}
judids.RemoveAt(0);
myUnOrderedList.Controls.Add(listItem);
}
}
fieldset.Controls.Add(myUnOrderedList);
Panel1.Controls.Add(fieldset);
Panel1.Visible = true;
}
}