protected void Page_Load(object sender, EventArgs e) { DropDownList homeCourtDropDownList = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("homeCourtDropDownList"); DropDownList leagueCityDropDownList = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("leagueCityDropDownList"); RadCaptcha radCaptcha = (RadCaptcha)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("radCaptcha"); RadAjaxManager radAjaxManage = RadAjaxManager.GetCurrent(Page); radAjaxManage.AjaxSettings.AddAjaxSetting(leagueCityDropDownList, homeCourtDropDownList); radAjaxManage.AjaxSettings.AddAjaxSetting(leagueCityDropDownList, radCaptcha); if (!Page.IsPostBack) { using (FlexibleTennisLeagueDataContext dataContext = new FlexibleTennisLeagueDataContext()) { List <SelectUniqueTennisCourtCitiesResult> selectUniqueTennisCourtCitiesResults = dataContext.SelectUniqueTennisCourtCities(Convert.ToInt32(WebConfigurationManager.AppSettings["LeagueCityId"])).ToList(); foreach (SelectUniqueTennisCourtCitiesResult result in selectUniqueTennisCourtCitiesResults) { leagueCityDropDownList.Items.Add(new ListItem(result.City, result.City)); } leagueCityDropDownList.Items[0].Selected = true; homeCourtDropDownList.Items.Add(string.Empty); List <TennisCourt> tennisCourts = dataContext.SelectTennisCourtByCity(selectUniqueTennisCourtCitiesResults[0].City, Convert.ToInt32(WebConfigurationManager.AppSettings["LeagueCityId"])).ToList(); foreach (TennisCourt tennisCourt in tennisCourts) { homeCourtDropDownList.Items.Add(new ListItem(tennisCourt.CourtName, tennisCourt.CourtId.ToString())); } } } }
protected void leagueCityDropDownList_SelectedIndexChanged(object sender, EventArgs e) { using (FlexibleTennisLeagueDataContext dataContext = new FlexibleTennisLeagueDataContext()) { DropDownList homeCourtDropDownList = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("homeCourtDropDownList"); DropDownList leagueCityDropDownList = (DropDownList)sender; List <TennisCourt> tennisCourts = dataContext.SelectTennisCourtByCity(leagueCityDropDownList.SelectedItem.Text, Convert.ToInt32(WebConfigurationManager.AppSettings["LeagueCityId"])).ToList(); homeCourtDropDownList.Items.Clear(); homeCourtDropDownList.Items.Add(string.Empty); foreach (TennisCourt tennisCourt in tennisCourts) { homeCourtDropDownList.Items.Add(new ListItem(tennisCourt.CourtName, tennisCourt.CourtId.ToString())); } } }
protected void tennisCourtsRadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) { using (FlexibleTennisLeagueDataContext dataContent = new FlexibleTennisLeagueDataContext()) { List <TennisCourt> tennisCourts = new List <TennisCourt>(); if (citiesDropDownList.SelectedItem.Text == "All Cities") { tennisCourts = dataContent.SelectTennisCourtsByLeague(Convert.ToInt32(WebConfigurationManager.AppSettings["LeagueCityId"])).ToList(); } else { tennisCourts = dataContent.SelectTennisCourtByCity(citiesDropDownList.SelectedItem.Text, Convert.ToInt32(WebConfigurationManager.AppSettings["LeagueCityId"])).ToList(); } tennisCourtsRadGrid.DataSource = tennisCourts; //tennisCourtsRadGrid.DataBind(); } }