protected void ctlAddNew_Click(object sender, ImageClickEventArgs e) { ctlTaxModalPopupExtender.Show(); ctlTaxGrid.DataCountAndBind(); ctlTaxForm.ChangeMode(FormViewMode.Insert); UpdatePanelTaxForm.Update(); }
protected void ctlTaxGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "UserEdit") { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; long taxId = Convert.ToInt64(ctlTaxGrid.DataKeys[rowIndex].Value); ctlTaxForm.PageIndex = (ctlTaxGrid.PageIndex * ctlTaxGrid.PageSize) + rowIndex; ctlTaxForm.ChangeMode(FormViewMode.Edit); IList<DbTax> taxList = new List<DbTax>(); DbTax tax = DbTaxService.FindByIdentity(taxId); taxList.Add(tax); ctlTaxForm.DataSource = taxList; ctlTaxForm.DataBind(); ctlTaxGrid.DataCountAndBind(); UpdatePanelTaxForm.Update(); ctlTaxModalPopupExtender.Show(); } else if (e.CommandName == "UserDelete") { try { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; long taxId = Convert.ToInt64(ctlTaxGrid.DataKeys[rowIndex].Value); DbTax tax = DbTaxService.FindByIdentity(taxId); DbTaxService.Delete(tax); } 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); ctlTaxGrid.DataCountAndBind(); ctlUpdatePanelGridview.Update(); } } ctlTaxGrid.DataCountAndBind(); ctlUpdatePanelGridview.Update(); } else if (e.CommandName == "Company") { int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; long taxId = Convert.ToInt64(ctlTaxGrid.DataKeys[rowIndex].Value); ctlCompanyTaxInfo1.Initialize(taxId); ctlCompanyTaxInfo1.Show(); } }