protected void ProfilesGrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { int id = (int)this.ProfilesGrid.DataKeys[e.RowIndex].Values["PersonID"]; // int perid= (int) Convert.ToInt16(this.ProfilesGrid.SelectedDataKey.Value); //{ string SQL = "UPDATE People SET Deleted = 1 WHERE PersonID = " + id.ToString(); // e.CommandArgument; Util.DoCmd(SQL); int pi = ProfilesGrid.PageIndex * 19; if (Session["dts"] != null) { DataSet dts = (DataSet)Session["dts"]; dts.Tables[0].Rows[e.RowIndex+pi].Delete(); dts.Tables[0].AcceptChanges(); ProfilesGrid.DataSource = dts; ProfilesGrid.DataBind(); Session["dts"] = dts; } LinkButton UndoDel = (LinkButton)this.plchStatusControls.FindControl("UndoDel"); UndoDel.Text = "Undo"; UndoDel.Visible = true; UndoDel.CommandName = "Undelete"; UndoDel.CausesValidation = false; clseditmode.personid = id.ToString(); UndoDel.CommandArgument = id.ToString(); // DataRowView view = e.RowIndex .DataItem as DataRowView; // string PersonName = view["FirstName"].ToString() + " " + view["LastName"].ToString(); this.DisplayMessage("Removed click to "); }And this was the original code
protected void ProfilesGrid_RowDeleted(object sender, GridViewDeletedEventArgs e) { if (e.Exception == null) { //LinkButton UndoDel = new LinkButton(); // NN 05-08-08 - added LinkButton on the page itself rather than adding in run-time LinkButton UndoDel = (LinkButton)this.plchStatusControls.FindControl("UndoDel"); UndoDel.Text = "Undo"; UndoDel.Visible = true; UndoDel.CommandName = "Undelete"; UndoDel.CausesValidation = false; clseditmode.personid = e.Keys["PersonID"].ToString(); UndoDel.CommandArgument = e.Keys["PersonID"].ToString(); this.DisplayMessage("Removed " + e.Values["FirstName"] + " " + e.Values["LastName"] + " click to "); } }