protected void ctlCountryGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "UserEdit") { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; CTID = Convert.ToInt16(ctlCountryGrid.DataKeys[rowIndex].Value); CountryEditor.Initialize(FlagEnum.EditFlag, CTID); CountryEditor.ShowPopUp(); } if (e.CommandName == "UserDelete") { try { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; CTID = UIHelper.ParseShort(ctlCountryGrid.DataKeys[rowIndex].Value.ToString()); DbCountry ct = ScgDbQueryProvider.DbCountryQuery.FindByIdentity(CTID); DbCountryService.Delete(ct); } catch (Exception ex) { if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData", "alert('This data is now in use.');", true); ctlCountryGrid.DataCountAndBind(); } } ctlCountryGrid.DataCountAndBind(); ctlUpdatePanelGridview.Update(); } }
protected void ctlAddNew_Click(object sender, ImageClickEventArgs e) { CountryEditor.Initialize(FlagEnum.NewFlag, 0); CountryEditor.ShowPopUp(); }