protected void GridViewMajor_RowDeleting(object sender, GridViewDeleteEventArgs e) { string strScript = string.Empty; HiddenField hddbudget_money_major_id = (HiddenField)GridViewMajor.Rows[e.RowIndex].FindControl("hddbudget_money_major_id"); cBudget_money oBudget_money = new cBudget_money(); try { oBudget_money.SP_BUDGET_MONEY_MAJOR_DEL(hddbudget_money_major_id.Value); setData(); strScript = "window.parent.__doPostBack('ctl00$ContentPlaceHolder1$LinkButton1','');"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "OpenPage", strScript, true); } catch (Exception ex) { if (ex.Message.Contains("REFERENCE constraint")) { MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว"); } else { lblError.Text = ex.Message.ToString(); } } finally { oBudget_money.Dispose(); } BindGridView(); }