protected void btnSaveCity_OnClick(object sender, EventArgs e)
        {
            var txtName = fvCity.FindControl("txtName") as TextBox;
            var countryId = Convert.ToInt32(GetDdlValue(fvCity, "ddlCountry"));

            var cityManager = new CityManager();
            var countryManager = new CountryManager();

            if (fvCity.CurrentMode == FormViewMode.Insert)
            {
                var city = new City();
                city.Name = txtName.Text;
                city.Country = countryManager.Get(countryId);
                cityManager.Add(city);
            }
            if (fvCity.CurrentMode == FormViewMode.Edit)
            {
                var city = cityManager.Get(currentId);
                city.Name = txtName.Text;
                city.Country = countryManager.Get(countryId);
                cityManager.Update(city);
            }
            gvCities.DataBind();
            PopupHelper.HidePopup("#popCity", this);
        }
        protected void btnSaveCountry_OnClick(object sender, EventArgs e)
        {
            var txtName = fvAddressEdit.FindControl("txtName") as TextBox;

            var countryManager = new CountryManager();

            if (fvAddressEdit.CurrentMode == FormViewMode.Edit)
            {
                var country = countryManager.Get(currentId);
                country.Name = txtName.Text;
                countryManager.Update(country);
            }
            if (fvAddressEdit.CurrentMode == FormViewMode.Insert)
            {
                var country = new Country();
                country.Name = txtName.Text;
                countryManager.Add(country);
            }

            gvCounties.DataBind();
            PopupHelper.HidePopup("#pop", this);
        }
 protected void gvCounties_OnRowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Modify")
     {
         var countryManager = new CountryManager();
         fvAddressEdit.ChangeMode(FormViewMode.Edit);
         currentId = Convert.ToInt32(e.CommandArgument);
         var temp = new List<DataModel.Model.Country>();
         // Bind data
         temp.Add(countryManager.Get(currentId));
         fvAddressEdit.DataSource = temp;
         fvAddressEdit.DataBind();
         PopupHelper.ShowPopup("#pop", this);
     }
 }