protected void btnChangeFlag_Click(object sender, EventArgs e)
        {
            var db = new WorldEntities();
            Country selected = new Country();
            if(this.GridViewCountries.SelectedIndex >= 0)
            {
                selected = db.Countries.Find(int.Parse(this.GridViewCountries.SelectedValue.ToString()));
            }

            if (this.changeFlagPicture.HasFile)
            {
                Byte[] imgByte = null;
                HttpPostedFile File = this.changeFlagPicture.PostedFile;
                imgByte = new Byte[File.ContentLength];
                File.InputStream.Read(imgByte, 0, File.ContentLength);
                selected.Flag = imgByte;
                db.SaveChanges();
            }

            this.GridViewCountries.DataBind();
        }
 protected void btnSaveCountry_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.txtCountryName.Text) &&
         !string.IsNullOrEmpty(this.txtCountryLanguage.Text) &&
         this.flagPicture.HasFile &&
         this.ListBoxContinents.SelectedIndex >= 0)
     {
         Byte[] imgByte = null;
         HttpPostedFile File = this.flagPicture.PostedFile;
         imgByte = new Byte[File.ContentLength];
         File.InputStream.Read(imgByte, 0, File.ContentLength);
         var db = new WorldEntities();
         var newCountry = new Country();
         newCountry.Name = Server.HtmlEncode(this.txtCountryName.Text);
         newCountry.Population = int.Parse(this.txtCountryPopulation.Text);
         newCountry.Language = Server.HtmlEncode(this.txtCountryLanguage.Text);
         newCountry.ContinentId = int.Parse(this.ListBoxContinents.SelectedValue);
         newCountry.Flag = imgByte;
         db.Countries.Add(newCountry);
         db.SaveChanges();
         this.GridViewCountries.DataBind();
     }
 }