protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
            userManager = new BLLUserMngr();
            user = userManager.BLLGetCurrentUser(Session);
            }
            catch (Exception)
            {
                //Log error
                Response.Redirect("404.aspx", false);
            }
            if (!IsPostBack)
            {
                /*Retrieve and load the values of each attribute*/
                attManager = new BLLAttributeMngr();
                hobbies = attManager.BLLGetHobbiesTable();

                attributes = attManager.BLLGetBuild();
                ddlBuild.DataSource = attributes;
                ddlBuild.DataBind();

                attributes = attManager.BLLGetCounty();
                ddlCounty.DataSource = attributes;
                ddlCounty.DataBind();

                attributes = attManager.BLLGetEthnicity();
                ddlEthnicity.DataSource = attributes;
                ddlEthnicity.DataBind();

                attributes = attManager.BLLGetEyeColor();
                ddlEyeColor.DataSource = attributes;
                ddlEyeColor.DataBind();

                attributes = attManager.BLLGetGenders();
                ddlGender.DataSource = attributes;
                ddlGender.DataBind();

                attributes = attManager.BLLGetHairColor();
                ddlHairColor.DataSource = attributes;
                ddlHairColor.DataBind();

                attributes = attManager.BLLGetHeight();
                ddlHeight.DataSource = attributes;
                ddlHeight.DataBind();

                attributes = attManager.BLLGetRelationshipStatus();
                ddlRelationshipStatus.DataSource = attributes;
                ddlRelationshipStatus.DataBind();

                attributes = attManager.BLLGetSexualOrientation();
                ddlOrientation.DataSource = attributes;
                ddlOrientation.DataBind();

                cblHobbies.DataSource = hobbies;
                cblHobbies.DataValueField = Resources.HOBBIES_ID_COLUMN;
                cblHobbies.DataTextField = Resources.HOBBIES_NAME_COLUMN;
                cblHobbies.DataBind();

                if (user != null)
                {
                    if (user.Age != null && user.Age > 0) txtAge.Text = user.Age.ToString();
                    if (user.IdealDate!=null && user.IdealDate.Length > 0) txtIdealDate.Text = user.IdealDate;
                    if (user.Profession != null && user.Profession.Length > 0) txtProfession.Text = user.Profession;
                    if (user.Town != null && user.Town.Length > 0) txtTown.Text = user.Town;
                    if (user.Comments != null && user.Comments.Length > 0) txtComments.Text = user.Comments;

                    if (user.Build != null && user.Build.Length > 0) ddlBuild.Items.FindByValue(user.Build).Selected = true;
                    if (user.County != null && user.County.Length > 0) ddlCounty.Items.FindByValue(user.County).Selected = true;
                    if (user.Ethnicity != null && user.Ethnicity.Length > 0) ddlEthnicity.Items.FindByValue(user.Ethnicity).Selected = true;
                    if (user.EyeColor != null && user.EyeColor.Length > 0) ddlEyeColor.Items.FindByValue(user.EyeColor).Selected = true;
                    if (user.Gender != null && user.Gender.Length > 0) ddlGender.Items.FindByValue(user.Gender).Selected = true;
                    if (user.HairColor != null && user.HairColor.Length > 0) ddlHairColor.Items.FindByValue(user.HairColor).Selected = true;
                    if (user.Height != null && user.Height.Length > 0) ddlHeight.Items.FindByValue(user.Height).Selected = true;
                    if (user.RelationshipStatus != null && user.RelationshipStatus.Length > 0) ddlRelationshipStatus.Items.FindByValue(user.RelationshipStatus).Selected = true;
                    if (user.SexualOrientation != null && user.SexualOrientation.Length > 0) ddlOrientation.Items.FindByValue(user.SexualOrientation).Selected = true;

                    // Populate the CheckBoxList items only when it's not a postback.
                    foreach (int i in user.Hobbies)
                    {
                        cblHobbies.Items[i].Selected = true;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /*
         * Populate Dropdown Lists
         */
        private void fillRegistrationData()
        {
            attManager = new BLLAttributeMngr();

            List<string> attributes;
            try
            {
            attributes = attManager.BLLGetGenders();
            ddlGender.DataSource = attributes;
            ddlGender.DataBind();

            attributes = attManager.BLLGetSexualOrientation();
            ddlOrientation.DataSource = attributes;
            ddlOrientation.DataBind();

            attributes = attManager.BLLGetCounty();
            ddlCounty.DataSource = attributes;
            ddlCounty.DataBind();
            }
            catch (Exception)
            {
                //Log error
                Response.Redirect("404.aspx", false);
            }
        }