protected void LoadCity() { DataTable CityDataTable = null; try { CityDataTable = CityBLL.GetCityByCountry(uoDropDownListCountryPerRegion.SelectedValue, uoTextBoxCity.Text, uoDropDownListLetters.SelectedValue); uoDropDownListCity.Items.Clear(); ListItem item = new ListItem("--Select City--", "0"); uoDropDownListCity.Items.Add(item); uoDropDownListCity.DataSource = CityDataTable; uoDropDownListCity.DataTextField = "colCityNameVarchar"; uoDropDownListCity.DataValueField = "colCityIDInt"; uoDropDownListCity.DataBind(); } catch (Exception ex) { throw ex; } finally { if (CityDataTable != null) { CityDataTable.Dispose(); } } }
/// <summary> /// Date Created: 29/07/2011 /// Created By: Gabriel Oquialda /// (description) Loads vendor city to dropdownlist /// ---------------------------------------------------- /// Date Modified: 05/Aug/2013 /// Created By: Josephine Gad /// (description) Change CityListbyCountry to CityBLL.GetCityByCountry /// Add Session, Add default value /// </summary> private void vendorCityLoad(Int16 iLoad, string vendorCountryId) { DataTable dt = null; try { if (iLoad == 0) { List <CityList> listCity = new List <CityList>(); uoDropDownListCity.Items.Clear(); if (Session["CityList"] != null) { listCity = ((List <CityList>)Session["CityList"]); uoDropDownListCity.DataSource = listCity; uoDropDownListCity.DataTextField = "CityName"; uoDropDownListCity.DataValueField = "CityId"; } uoDropDownListCity.Items.Insert(0, (new ListItem("--Select City--", "0"))); uoDropDownListCity.DataBind(); } else { //dt = CityBLL.CityListbyCountry(vendorCountryId); dt = CityBLL.GetCityByCountry(vendorCountryId, uoTextBoxCity.Text.Trim(), uoTextBoxCity.Text); uoDropDownListCity.Items.Clear(); uoDropDownListCity.Items.Insert(0, new ListItem("--Select a City--", "")); if (dt.Rows.Count > 0) { uoDropDownListCity.DataSource = dt; uoDropDownListCity.DataTextField = "colCityNameVarchar"; uoDropDownListCity.DataValueField = "colCityIDInt"; uoDropDownListCity.DataBind(); if (dt.Rows.Count == 1) { if (uoDropDownListCity.Items.FindByValue(GlobalCode.Field2String(dt.Rows[0]["colCityIDInt"])) != null) { uoDropDownListCity.SelectedValue = GlobalCode.Field2String(dt.Rows[0]["colCityIDInt"]); } } } else { uoDropDownListCity.DataBind(); } } } catch (Exception ex) { throw ex; } finally { if (dt != null) { dt.Dispose(); } } }
/// <summary> /// Date Created: 29/07/2011 /// Created By: Gabriel Oquialda /// (description) Loads vendor city to dropdownlist /// =============================================== /// Date Modified: 24/01/2012 /// Modified By: Josephine Gad /// (description) Replace CityListbyCountry with GetCityByCountry /// </summary> private void vendorCityLoad(int vendorCountryId) { DataTable dt = null; try { //dt = CityBLL.CityListbyCountry(vendorCountryId); dt = CityBLL.GetCityByCountry(vendorCountryId.ToString(), uoTextBoxCityName.Text.Trim(), "0"); if (dt.Rows.Count > 0) { uoDropDownListCity.DataSource = dt; uoDropDownListCity.DataTextField = "colCityNameVarchar"; uoDropDownListCity.DataValueField = "colCityIDInt"; uoDropDownListCity.DataBind(); uoDropDownListCity.Items.Insert(0, new ListItem("--Select City--", "0")); } else { uoDropDownListCity.DataBind(); uoDropDownListCity.Items.Insert(0, new ListItem("--Select City--", "0")); } } catch (Exception ex) { throw ex; } finally { if (dt != null) { dt.Dispose(); } } }
/// <summary> /// Date Created: 28/09/2011 /// Created By: Josephine Gad /// (description) Get city by country id /// --------------------------------------------------------------------------- /// </summary> private void BindCity() { DataTable CityDataTable = null; try { CityDataTable = CityBLL.GetCityByCountry(uoDropDownListCountry.SelectedValue, uoTextBoxCityName.Text, "0"); uoDropDownListCity.Items.Clear(); ListItem item = new ListItem("--Select City--", "0"); uoDropDownListCity.Items.Add(item); uoDropDownListCity.DataSource = CityDataTable; uoDropDownListCity.DataTextField = "colCityNameVarchar"; uoDropDownListCity.DataValueField = "colCityIDInt"; uoDropDownListCity.DataBind(); if (GlobalCode.Field2String(Session["City"]) != "") { if (uoDropDownListCity.Items.FindByValue(GlobalCode.Field2String(Session["City"])) != null) { uoDropDownListCity.SelectedValue = GlobalCode.Field2String(Session["City"]); } } } catch (Exception ex) { throw ex; } finally { if (CityDataTable != null) { CityDataTable.Dispose(); } } }
/// <summary> /// Date Created: 07/09/2011 /// Created By: Gabriel Oquialda /// (description) Select city list by vendor and country id /// </summary> private void cityListByCountry(int vendorCountryId) { DataTable dt = null; try { dt = CityBLL.GetCityByCountry(uoDropDownListCountry.SelectedValue, uoTextBoxFilterCity.Text.Trim(), "0"); ListItem item = new ListItem("--SELECT CITY--", "0"); uoDropDownListCity.Items.Clear(); uoDropDownListCity.Items.Add(item); if (dt.Rows.Count > 0) { uoDropDownListCity.DataTextField = "colCityNameVarchar"; uoDropDownListCity.DataValueField = "colCityIDInt"; uoDropDownListCity.DataSource = dt; } uoDropDownListCity.DataBind(); if (dt.Rows.Count == 1) { uoDropDownListCity.SelectedIndex = 1; } } catch (Exception ex) { throw ex; } finally { if (dt != null) { dt.Dispose(); } } //DataTable dt = null; //try //{ // int countryID = 0; // if (uoDropDownListCountry.SelectedValue != "0") // { // countryID = Convert.ToInt32(uoDropDownListCountry.SelectedValue); // } // uoDropDownListCity.Items.Clear(); // dt = VendorMaintenanceBLL.cityListByCountry(countryID); // if (dt.Rows.Count > 0) // { // uoDropDownListCity.DataSource = dt; // uoDropDownListCity.DataTextField = "colCityNameVarchar"; // uoDropDownListCity.DataValueField = "colCityIDInt"; // uoDropDownListCity.DataBind(); // } // else // { // uoDropDownListCity.DataBind(); // } // uoDropDownListCity.Items.Insert(0, (new ListItem("--Select City--", "0"))); // if (dt.Rows.Count == 1) // { // uoDropDownListCity.SelectedIndex = 1; // } //} //catch (Exception ex) //{ // throw ex; //} //finally //{ // if (dt != null) // { // dt.Dispose(); // } //} }