protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e) { string strMsg = string.Empty; if (e.CommandName == "cmdedit") { Response.Redirect("PurchaseBill.aspx?PB=" + e.CommandArgument, true); } if (e.CommandName == "cmddelete") { PurchaseBillDAL obj = new PurchaseBillDAL(); Int32 intValue = obj.DeletePurchaseBill(Convert.ToInt32(e.CommandArgument)); obj = null; if (intValue > 0) { this.BindGrid(); strMsg = "Record deleted successfully."; txtBillNo.Focus(); } else { if (intValue == -1) { strMsg = "Record can not be deleted. It is in use."; } else { strMsg = "Record not deleted."; } } ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true); } }