protected void Delete(object sender, EventArgs e) { GridViewRow gvr = (GridViewRow)(((Control)sender).NamingContainer); { LinkButton imgEdit = (LinkButton)gvr.FindControl("lnkEdit"); LinkButton imgDelete = (LinkButton)gvr.FindControl("linkDelete"); Label lblID = (Label)gvr.FindControl("lblProgramsID"); DataTable dt = new DataTable(); objML_Logn.ID = lblID.Text != "" ? lblID.Text : null; dt = objBL_Login.BL_ChecUser_UsedOrNot(objML_Logn); if (dt.Rows.Count < 0) { int x = objBL_Login.BL_DeleteUser(objML_Logn); if (x == 1) { ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Data Delete')", true); BindProgramsInfo(); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Already User Used for exam !')", true); } } }