protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     int cityId = int.Parse(e.CommandArgument.ToString());
     TerritorySite.BL.CMS.City thisCity = new TerritorySite.BL.CMS.City(cityId);
     thisCity.RemoveFromAccount();
     DoDataBind();
 }
 protected void ButtonSave_Click(object sender, EventArgs e)
 {
     TerritorySite.BL.CMS.City selectedCity = new TerritorySite.BL.CMS.City(this.DropDownListCityList.SelectedValue);
     selectedCity.AssociateWithCurrentAccount();
     DoDataBind();
     // if it does exist don't do anything
     // if it does not existist : Create it, add it to the account.
 }
    protected void Button1_Click(object sender, EventArgs e)
    {
        // search if the city already exists
        TerritorySite.BL.CMS.City findMe = new TerritorySite.BL.CMS.City();
        findMe.StateProvinceId = int.Parse(this.DropDownListStates.SelectedValue);
        findMe.Description = TextBoxNewCity.Text.Trim();
        TerritorySite.BL.CMS.CityCollection foundCities = new TerritorySite.BL.CMS.CityCollection();
        foundCities.LoadAndCloseReader(TerritorySite.BL.CMS.City.Find(findMe));
        if (foundCities.Count == 0)
        {
            findMe.StateProvinceId = int.Parse(this.DropDownListStates.SelectedValue);
            findMe.Description = TextBoxNewCity.Text.Trim();
            findMe.Save();
            findMe.AssociateWithCurrentAccount();

        }
        else
        {
            foundCities[0].AssociateWithCurrentAccount();
        }
        DoDataBind();
        TextBoxNewCity.Text = string.Empty;
    }