protected void ddlCounty_SelectedIndexChanged(object sender, EventArgs e) { DropDownList ddlCounty = (DropDownList)sender; DropDownList ddlTownshipNY = (DropDownList)fvProperty.FindControl("ddlTownshipNY"); DropDownList ddlBasin = (DropDownList)fvProperty.FindControl("ddlbasin"); DropDownList ddlSubbasin = (DropDownList)fvProperty.FindControl("ddlSubbasin"); if (!string.IsNullOrEmpty(ddlCounty.SelectedValue)) { WACGlobal_Methods.PopulateControl_DatabaseLists_TownshipNY_DDL(ddlTownshipNY, Convert.ToInt32(ddlCounty.SelectedValue), null); if (_CountyControlsBasin) { WACGlobal_Methods.PopulateControl_DatabaseLists_Basin_DDL(ddlBasin, null, null, null, Convert.ToInt32(ddlCounty.SelectedValue), null, true); if (_BoolShowSubbasin) { ddlSubbasin.Items.Clear(); } } } else { if (_BoolShowTownship) { ddlTownshipNY.Items.Clear(); } if (_CountyControlsBasin) { ddlBasin.Items.Clear(); if (_BoolShowSubbasin) { ddlSubbasin.Items.Clear(); } } } }
protected void ddlZip_SelectedIndexChanged(object sender, EventArgs e) { DropDownList ddl = (DropDownList)sender; DropDownList ddlState = fvProperty.FindControl("ddlState") as DropDownList; DropDownList ddlCountyNY = fvProperty.FindControl("ddlCounty") as DropDownList; DropDownList ddlTownshipNY = fvProperty.FindControl("ddlTownshipNY") as DropDownList; DropDownList ddlBasin = fvProperty.FindControl("ddlBasin") as DropDownList; DropDownList ddlSubbasin = fvProperty.FindControl("ddlSubbasin") as DropDownList; TextBox tbCity = fvProperty.FindControl("tbCity") as TextBox; using (WACDataClassesDataContext wDataContext = new WACDataClassesDataContext()) { var a = (from b in wDataContext.zipcodes.Where(w => w.pk_zipcode == ddl.SelectedValue) select b).Single(); if (ddlState.SelectedValue.ToUpper() == "NY") { try { var c = wDataContext.list_countyNies.Where(w => w.county == a.county).Select(s => s.pk_list_countyNY); if (c.Count() == 1) { WACGlobal_Methods.PopulateControl_DatabaseLists_CountyNY_DDL(ddlCountyNY, false, c.Single()); WACGlobal_Methods.PopulateControl_DatabaseLists_TownshipNY_DDL(ddlTownshipNY, c.Single(), null); WACGlobal_Methods.PopulateControl_DatabaseLists_Basin_DDL(ddlBasin, null, null, null, c.Single(), null, true); ddlSubbasin.Items.Clear(); } else { WACGlobal_Methods.PopulateControl_DatabaseLists_CountyNY_DDL(ddlCountyNY, false, null); ddlTownshipNY.Items.Clear(); ddlBasin.Items.Clear(); ddlSubbasin.Items.Clear(); } } catch { ddlCountyNY.SelectedIndex = 0; ddlTownshipNY.Items.Clear(); ddlBasin.Items.Clear(); ddlSubbasin.Items.Clear(); tbCity.Text = ""; } } else { ddlCountyNY.Items.Clear(); ddlTownshipNY.Items.Clear(); ddlBasin.Items.Clear(); ddlSubbasin.Items.Clear(); } tbCity.Text = a.city; } }
private void BindProperty(int i) { using (WACDataClassesDataContext wDataContext = new WACDataClassesDataContext()) { var a = from b in wDataContext.properties.Where(w => w.pk_property == i) select b; fvProperty.DataKeyNames = new string[] { "pk_property" }; fvProperty.DataSource = a; fvProperty.DataBind(); if (fvProperty.CurrentMode == FormViewMode.ReadOnly) { if (i > 0) { WACUT_Associations assoc = fvProperty.FindControl("WACUT_Associations") as WACUT_Associations; List <WACParameter> parms = new List <WACParameter>(); parms.Add(new WACParameter("pk_property", i, WACParameter.ParameterType.SelectedKey)); parms.Add(new WACParameter("pk_property", i, WACParameter.ParameterType.PrimaryKey)); assoc.InitControl(parms); parms = null; } } if (fvProperty.CurrentMode == FormViewMode.Insert) { WACGlobal_Methods.PopulateControl_DatabaseLists_StatesUS_DDL(fvProperty, "ddlState", "NY"); WACGlobal_Methods.PopulateControl_DatabaseLists_Zipcode_DDL(fvProperty, "ddlZip", null, "NY"); } if (fvProperty.CurrentMode == FormViewMode.Edit) { WACGlobal_Methods.PopulateControl_DatabaseLists_StatesUS_DDL(fvProperty, "ddlState", a.Single().state); WACGlobal_Methods.PopulateControl_DatabaseLists_Zipcode_DDL(fvProperty, "ddlZip", a.Single().fk_zipcode, a.Single().state); WACGlobal_Methods.PopulateControl_DatabaseLists_CountyNY_DDL(fvProperty.FindControl("ddlCounty") as DropDownList, false, a.Single().fk_list_countyNY); if (a.Single().fk_list_countyNY != null) { WACGlobal_Methods.PopulateControl_DatabaseLists_TownshipNY_DDL(fvProperty.FindControl("ddlTownshipNY") as DropDownList, a.Single().fk_list_countyNY, a.Single().fk_list_townshipNY); WACGlobal_Methods.PopulateControl_DatabaseLists_Basin_DDL(fvProperty.FindControl("ddlBasin") as DropDownList, null, null, null, a.Single().fk_list_countyNY, a.Single().fk_basin_code, true); if (!string.IsNullOrEmpty(a.Single().fk_basin_code)) { WACGlobal_Methods.PopulateControl_DatabaseLists_Subbasin_DDL(fvProperty.FindControl("ddlSubbasin") as DropDownList, a.Single().fk_basin_code, a.Single().fk_subbasin_code); } } } } upProperty.Update(); }
public void BindProperty(int i) { using (WACDataClassesDataContext wDataContext = new WACDataClassesDataContext()) { var a = wDataContext.properties.Where(w => w.pk_property == i).Select(s => s); fvProperty.DataKeyNames = new string[] { "pk_property" }; fvProperty.DataSource = a; fvProperty.DataBind(); if (fvProperty.CurrentMode != FormViewMode.Insert) { hfPropertyPK.Value = a.Single().pk_property.ToString(); } if (fvProperty.CurrentMode == FormViewMode.Insert) { WACGlobal_Methods.PopulateControl_DatabaseLists_StatesUS_DDL(fvProperty, "ddlState", "NY"); WACGlobal_Methods.PopulateControl_DatabaseLists_Zipcode_DDL(fvProperty, "ddlZip", null, "NY"); } if (fvProperty.CurrentMode == FormViewMode.Edit) { WACGlobal_Methods.PopulateControl_DatabaseLists_StatesUS_DDL(fvProperty, "ddlState", a.Single().state); WACGlobal_Methods.PopulateControl_DatabaseLists_Zipcode_DDL(fvProperty, "ddlZip", a.Single().fk_zipcode, a.Single().state); WACGlobal_Methods.PopulateControl_DatabaseLists_CountyNY_DDL(fvProperty.FindControl("ddlCounty") as DropDownList, false, a.Single().fk_list_countyNY); if (a.Single().fk_list_countyNY != null) { WACGlobal_Methods.PopulateControl_DatabaseLists_TownshipNY_DDL(fvProperty.FindControl("ddlTownshipNY") as DropDownList, a.Single().fk_list_countyNY, a.Single().fk_list_townshipNY); WACGlobal_Methods.PopulateControl_DatabaseLists_Basin_DDL(fvProperty.FindControl("ddlBasin") as DropDownList, null, null, null, a.Single().fk_list_countyNY, a.Single().fk_basin_code, true); if (!string.IsNullOrEmpty(a.Single().fk_basin_code)) { WACGlobal_Methods.PopulateControl_DatabaseLists_Subbasin_DDL(fvProperty.FindControl("ddlSubbasin") as DropDownList, a.Single().fk_basin_code, a.Single().fk_subbasin_code); } } } } }