Asp.Net2.0动态创建用户控件

方法一 LoadControl 方法二 继承类 方法三 <%@ Reference Control="" %>应用 方法四 拖一个用户空件 综合应用 private void RADTabBind() { FieldInfo[] fields = typeof(EVR.DomainLayer.Enums.WeekDayEnum).GetFields(); int length = fields.Length; for (int i = 1; i < length; i++) { FieldInfo info = fields[i]; Tab tab = new Tab(); tab.Text = info.Name; RadTabStrip1.Tabs.Add(tab);

PageView pv = new PageView(); Literal ltl = new Literal(); //ltl.Text = info.Name + " 123"; pv.Controls.Add(ltl);

string controlname = "~/Schedule/UserControls/DailyList.ascx"; Schedule_UserControls_DailyList uc = (Schedule_UserControls_DailyList)this.LoadControl(controlname); uc.ID = "UC_" + info.Name; uc.Week_Day = info.Name; uc.ParentId = 0; uc.UserId = 0; uc.PageSize = 30; uc.PageVisible = 1; uc.CurrentPage = 1; uc.SortItem = ""; uc.TotalCount = 0; pv.Controls.Add(uc);

//Schedule_UserControls_DailyList list = new Schedule_UserControls_DailyList(); //list.ID = "list" + info.Name; //list.Week_Day = info.Name; ////list.Visible = false; //list.DataBind(); //this.LoadControl(list.AppRelativeVirtualPath); //pv.Controls.Add(list);

RadMultiPage1.PageViews.Add(pv);

}

你可能感兴趣的:(asp)