protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e) { if (Page.IsValid) { string name = ((TextBox)FormView1.FindControl("NameTextBox")).Text; // int carBodyId = int.Parse(Request.QueryString["id"]); if (CarBody.Exists(name, Id)) { // cancel update operation e.Cancel = true; this.ShowMessage(CarBodyDuplicateErrorMessage); } else { // update item bool archived = ((CheckBox)this.FormView1.FindControl("ArchivedCheckBox")).Checked; CarBody .Update(Id, name, archived); this.RefreshParentWindow(); this.ClosePopup(); } } }