using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class delete_user_form : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Session["out"].ToString() == "false") { Response.Redirect("log_out.aspx"); } else if (Session["u_type"].ToString() == "admin") { //con = new SqlConnection(ConfigurationManager.ConnectionStrings["regis_dbConnectionString"].ConnectionString); } else { Response.Redirect("log_out.aspx"); } } protected void link_btn_logout_Click(object sender, EventArgs e) { string session_check = "false"; Session["out"] = session_check; Response.Redirect("log_out.aspx"); } protected void link_btn_home_Click(object sender, EventArgs e) { if (Session["u_type"].ToString() == "admin") { Response.Redirect("admin_choice_form.aspx"); } else Response.Redirect("log_out.aspx"); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[1].Attributes.Add("onclick", ClientScript.GetPostBackEventReference(GridView1, "Select$" + e.Row.RowIndex.ToString())); // e.Row.Attributes.Add("onclick", //ClientScript.GetPostBackEventReference(GridView1, "Select$" + //e.Row.RowIndex.ToString())); e.Row.Style.Add("cursor", "pointer"); } } protected void btn_delete_Click(object sender, EventArgs e) { string usrid; foreach (GridViewRow gvrow in GridView1.Rows) { //Finiding checkbox control in gridview for particular row CheckBox chkdelete = (CheckBox)gvrow.FindControl("CheckBox1"); //Condition to check checkbox selected or not if (chkdelete.Checked) { //Getting UserId of particular row using datakey value //usrid = Convert.ToInt32(GridView1.DataKeys[gvrow.RowIndex].Value); usrid = GridView1.DataKeys[gvrow.RowIndex].Value.ToString(); SqlDataSource1.DeleteParameters["log_id"].DefaultValue = usrid.ToString(); SqlDataSource1.Delete(); //DeleteRecordByID(usrid); } } } }