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 gvCities_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Modify")
            {
                var cityManager = new CityManager();
                fvCity.ChangeMode(FormViewMode.Edit);

                currentId = Convert.ToInt32(e.CommandArgument);
                var temp = new List<DataModel.Model.City>();
                var ddlCountry = fvCity.FindControl("ddlCountry") as DropDownList;

                // Bind data
                var city = cityManager.Get(currentId);

                temp.Add(city);
                fvCity.DataSource = temp;
                fvCity.DataBind();

                PopupHelper.ShowPopup("#popCity", this);

            }
        }
 protected void ddlCountry_OnPreRender(object sender, EventArgs e)
 {
     var cityManager = new CityManager();
     var city = cityManager.Get(currentId);
     if(city.Country != null)
     {
         (sender as DropDownList).Items.FindByValue(city.Country.Id.ToString()).Selected = true;
     }
 }