protected void Page_Load(object sender, EventArgs e) { if (!Request.IsAuthenticated) { Response.Redirect(WebConfigurationManager.AppSettings["LoginPageURL"].ToString()); } ChangePassword1.SuccessPageUrl = WebConfigurationManager.AppSettings["SuccessPageURL"].ToString(); photoRadWindow1.NavigateUrl = WebConfigurationManager.AppSettings["PhotoUploadNavigateURL"].ToString(); //if (!Page.IsPostBack) //{ // upcomingLeagueButton.Attributes.Add("onclick", "this.style.display='none';"); //} using (FlexibleTennisLeagueDataContext dataContext = new FlexibleTennisLeagueDataContext()) { if (!Page.IsPostBack) { List <TennisCourt> tennisCourts = dataContext.SelectTennisCourtsByLeague(Convert.ToInt32(WebConfigurationManager.AppSettings["LeagueCityId"])).ToList(); homeCourtDropDownList.Items.Add(string.Empty); foreach (TennisCourt tennisCourt in tennisCourts) { homeCourtDropDownList.Items.Add(new ListItem(tennisCourt.CourtName, tennisCourt.CourtId.ToString())); } int userNextDivision = 0; ISingleResult <SelectUserByEmailIdResult> users = dataContext.SelectUserByEmailId(HttpContext.Current.User.Identity.Name); foreach (SelectUserByEmailIdResult user in users) { firstNameTextBox.Text = user.FirstName; lastNameTextBox.Text = user.LastName; zipTextBox.Text = user.Zip; phoneTextBox.Text = user.Phone; homeCourtDropDownList.SelectedValue = user.HomeCourt.ToString(); nTRPDropDownList.Text = user.NTRPRanking.ToString(); ageGroupDropDownList.SelectedValue = user.AgeGroup; racquetHandDropDownList.SelectedValue = user.RacquetHand; favoriteShotDropDownList.SelectedValue = user.FavoriteShot; racquetTextBox.Text = user.Racquet; facebookTextBox.Text = user.Facebook; linkedInTextBox.Text = user.LinkedIn; mySpaceTextBox.Text = user.MySpace; orkutTextBox.Text = user.Orkut; if (user.ProfileImageName.HasValue) { profileImage.ImageUrl = string.Format("~/ProfileImages/{0}.jpg", user.ProfileImageName.ToString()); } if (user.NextDivision.HasValue) { userNextDivision = user.NextDivision.Value; } if (user.EmailPost.HasValue) { postEmailCheckBox.Checked = user.EmailPost.Value; } playTypeDropDownList.SelectedValue = user.Interest; } //List<SelectDivisionByLeagueIdResult> selectDivisionByLeagueIdResult = dataContext.SelectDivisionByLeagueId(Convert.ToInt32(WebConfigurationManager.AppSettings["LeagueCityId"])).ToList(); //SelectDivisionByLeagueIdResult nextDivision = selectDivisionByLeagueIdResult.Find(p => p.DivisionId == selectDivisionByLeagueIdResult.Max(q => q.DivisionId)); List <SelectDivisionResult> selectDivisionResult = dataContext.SelectDivision(StoredData.User.NextDivision).ToList(); if (StoredData.User.Division != StoredData.User.NextDivision) { ViewState["NextDivision"] = StoredData.User.NextDivision; ViewState["NextDivisionText"] = selectDivisionResult[0].Division; upcomingLeagueLabel.Text = string.Format("{0} {1} - {2}", selectDivisionResult[0].Division, selectDivisionResult[0].StartDate.ToShortDateString(), selectDivisionResult[0].EndDate.ToShortDateString()); upcomingLeagueButton.Visible = true; } else { upcomingLeagueLabel.Text = string.Format("You are currently subscribed to the {0} {1} - {2}", selectDivisionResult[0].Division, selectDivisionResult[0].StartDate.ToShortDateString(), selectDivisionResult[0].EndDate.ToShortDateString()); } } List <SelectProfileImageByEmailIdResult> selectProfileImageByEmailIdResult = dataContext.SelectProfileImageByEmailId(HttpContext.Current.User.Identity.Name).ToList(); if (selectProfileImageByEmailIdResult.Count > 0) { profileImage.ImageUrl = string.Format("~/ProfileImages/{0}.jpg", selectProfileImageByEmailIdResult[0].ProfileImageName.ToString()); } } }