后台cs:
protected void Page_Load(object sender, EventArgs e)
{
ArrayList al;
if (Session["Controls"] != null)
{
al = (ArrayList)Session["Controls"];
PH.Controls.Clear();
for (int i = 0; i < al.Count; i++)
{
DropDownList ddl = (DropDownList)al[i];
ddl.SelectedIndexChanged += new EventHandler(dl_SelectedIndexChanged);
PH.Controls.Add(ddl);
}
}
if (!IsPostBack)
{
DataTable dtbl11 = limitedTree.LoadAllrootCategory(out strError);
CreateControls(dtbl11, 0);
}
}
void CreateControls(DataTable dtbl, int CurID)
{
ArrayList al;
if (Session["Controls"] == null)
al = new ArrayList();
else
{
al = (ArrayList)Session["Controls"];
for (int i = 0; i < al.Count; i++)
{
DropDownList ddl_Remove = (DropDownList)al[i];
if (Convert.ToInt32(ddl_Remove.ID) > CurID)
{
i--;
al.Remove(ddl_Remove);
PH.Controls.Remove(ddl_Remove);
}
}
}
if (dtbl.Rows.Count > 0)
{
DropDownList dl = new DropDownList();
CurID++;
dl.ID = CurID.ToString();
dl.AutoPostBack = true;
dl.SelectedIndexChanged += new EventHandler(dl_SelectedIndexChanged);