Mark This Response as Answer -- Chandu http://www.dotnetfunda.com/images/dnfmvp.gif
GridViewRow row = GridView1.Rows[e.RowIndex]; Label firstnamelable = (Label)row.FindControl("lblFirstNameValue"); string firstname = firstnamelable.Text; SqlCommand cmd1 = new SqlCommand("delete from tab1 where firstname='" + firstname + "'");
SqlCommand cmd1 = new SqlCommand("delete from tab1 where firstname='" + GridView1.DataKeys[e.RowIndex].Value.ToString()+ "'");
protected void gvDetails_RowDeleting(object sender, GridViewDeleteEventArgs e) { int userid = Convert.ToInt32(gvDetails.DataKeys[e.RowIndex].Values["UserId"].ToString()); string username = gvDetails.DataKeys[e.RowIndex].Values["UserName"].ToString(); con.Open(); SqlCommand cmd = new SqlCommand("delete from Employee_Details where UserId=" + userid, con); int result = cmd.ExecuteNonQuery(); con.Close(); if (result == 1) { BindEmployeeDetails(); lblresult.ForeColor = Color.Red; lblresult.Text = username + " details deleted successfully"; } }
Login to post response