public void Update() { try { if (hd.Value != "true") { lblcheckDoubleError.Text = string.Empty; //GridViewRow row = GridView1.SelectedRow; int category_id = Convert.ToInt32(hdcategoryid.Value); //context.sp_UpdateCategory(c_id, category_id, b_id, txtCategoryName.Text, "admin", DateTime.Today); context.sp_UpdateCategory(companyId, category_id, txtCategoryName.Text, Convert.ToString(Session["UserID"]), DateTime.Today); btnctgryUpdate.Visible = false; btnctgrySave123.Visible = true; ViewState["gridrow"] = null; ((Category)this.Page).loadDataTable(); divalert.Visible = true; lblAlert.Text = "Category Update Successfully."; txtCategoryName.Text = string.Empty; } else { divalert.Visible = false; lblcheckDoubleError.ForeColor = System.Drawing.Color.Red; lblcheckDoubleError.Text = "Category Name Already Exists."; return; } } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }