protected void Page_Load(object sender, EventArgs e) { if (Session["UserID"] == null) { Response.Redirect("HomePage.aspx", true); } if (!IsPostBack) { Session["ShownUsers"] = null; } List <Profession> profList = Profession.GetProfessionList(); DropDownProfFilter.DataTextField = "ProfName"; DropDownProfFilter.DataValueField = "ProfessionID"; DropDownProfFilter.DataSource = profList; int this_year = DateTime.Now.Year; DropDownAgeFilter.DataSource = Enumerable.Range(1, this_year - 1940).ToList(); DropDownLanguageFilter.DataSource = GeneralMethods.GetLang(); DropDownLanguageFilter.DataTextField = "Value"; DropDownLanguageFilter.DataValueField = "Key"; DropDownWeeklyHoursFilter.DataSource = Enumerable.Range(1, 50).ToList(); List <UserInfo> users = ReturnUsersDefaultList(0); UsersRepeater.DataSource = users; UsersRepeater.DataBind(); if (!Page.IsPostBack) { if (UsersRepeater.HasControls()) { Label LastUserID = (Label)UsersRepeater.Controls[UsersRepeater.Items.Count - 1].FindControl("UserID"); if (LastUserID != null) { ShownUserIndex.Value = LastUserID.Text; } } DropDownProfFilter.DataBind(); DropDownProfFilter.Items.Insert(0, new ListItem("none", "-1")); DropDownAgeFilter.DataBind(); DropDownAgeFilter.Items.Insert(0, new ListItem("none", "-1")); DropDownLanguageFilter.DataBind(); DropDownLanguageFilter.Items.Insert(0, new ListItem("none", "-1")); DropDownWeeklyHoursFilter.DataBind(); DropDownWeeklyHoursFilter.Items.Insert(0, new ListItem("none", "0")); } }
public static void BindProfessions(HtmlControl ctrl, Page thispage) { List <Profession> Plist = Profession.GetProfessionList(); foreach (Profession p in Plist) { HtmlInputCheckBox rd_button = new HtmlInputCheckBox(); const string GROUP_NAME = "Professions"; rd_button.Name = GROUP_NAME; string LinkID = "Prof" + p.ProfessionID.ToString(); rd_button.ID = LinkID; rd_button.Value = p.ProfessionID.ToString(); RegisterUserControl userprofession = (RegisterUserControl)thispage.LoadControl("~/RegisterUserControl.ascx"); userprofession.imgP = p.ProfPath; userprofession.fieldName = p.ProfName; userprofession.IDnum = p.ProfessionID; userprofession.RadioName = "ContentPlaceHolder1_" + LinkID; userprofession.EnableViewState = true; rd_button.EnableViewState = true; ctrl.Controls.Add(rd_button); ctrl.Controls.Add(userprofession); } }