protected void btnSubmit_Click(object sender, EventArgs e) { try { if (hid.Value == "Update") { FleetLocation loc = null; bool rst = false; loc = LookUpBLL.GetFleetLocation(Convert.ToInt32(txtID.Text)); if (loc != null) { loc.Name = txtDept.Text.ToUpper();; rst = LookUpBLL.UpdateFleetLocation(loc); if (rst != false) { BindGrid(); success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record updated successfully!!."; return; } } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not updated. Kindly try again. If error persist contact Administrator!!."; } } else { string typ = ""; typ = txtDept.Text; bool result = false; FleetLocation loc = new FleetLocation(); loc.Name = typ.ToUpper(); result = LookUpBLL.AddFleetLocation(loc); if (result) { BindGrid(); txtDept.Text = ""; success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record added successfully!!."; return; } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not added. Kindly try again. If error persist contact Administrator!!."; } } } catch (Exception ex) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + ex.Message); } }