protected void GrdViewBilit_RowDeleted(object sender, GridViewDeletedEventArgs e) { try { if (e.Exception == null) { GrdViewBilit.DataBind(); } else { if (e.Exception.InnerException != null) { StringBuilder script = new StringBuilder(); script.Append("alert('You are not allowed to delete the record. Please contact Supervisor.');"); if (e.Exception.InnerException.Message.IndexOf("Invalid Date") > -1) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), script.ToString(), true); } e.ExceptionHandled = true; } } } catch (Exception ex) { TroyLiteExceptionManager.HandleException(ex); } }
protected void frmViewAdd_ItemInserted(object sender, FormViewInsertedEventArgs e) { try { if (e.Exception == null) { lnkBtnAdd.Visible = true; frmViewAdd.Visible = false; System.Threading.Thread.Sleep(1000); GrdViewBilit.DataBind(); //MyAccordion.Visible = true; GrdViewBilit.Visible = true; UpdatePanel16.Update(); ModalPopupExtender1.Hide(); StringBuilder scriptMsg = new StringBuilder(); scriptMsg.Append("alert('Bilty Saved Successfully.');"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), scriptMsg.ToString(), true); } else { StringBuilder script = new StringBuilder(); script.Append("alert('You are not allowed to Update this record. Please contact Supervisor.');"); e.KeepInInsertMode = true; if (e.Exception.InnerException != null) { if (e.Exception.InnerException.Message.IndexOf("because they would create duplicate values in the index") != -1) { e.ExceptionHandled = true; ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('ChalanNo and Bilty No. already exists. Please try again.');", true); return; } if (e.Exception.InnerException.Message.IndexOf("Invalid Date") == -1) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Exception Occured : " + e.Exception.InnerException.Message + "');", true); } } e.KeepInInsertMode = true; e.ExceptionHandled = true; lnkBtnAdd.Visible = false; frmViewAdd.Visible = true; ModalPopupExtender1.Show(); } } catch (Exception ex) { TroyLiteExceptionManager.HandleException(ex); } }
protected void btnSearch_Click(object sender, EventArgs e) { try { rvSearch.Enabled = true; Page.Validate(); if (Page.IsValid) { GrdViewBilit.DataBind(); } } catch (Exception ex) { TroyLiteExceptionManager.HandleException(ex); } }