protected void ProfilesGrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { if (!clseditmode.dlt) { clseditmode.dlt = true; string PersonName; DataRowView view = ProfilesGrid.Rows[e.RowIndex].DataItem as DataRowView; if (view != null) PersonName = view["FirstName"].ToString() + " " + view["LastName"].ToString(); else PersonName = ProfilesGrid.Rows[e.RowIndex].Cells[6].Text + " " + ProfilesGrid.Rows[e.RowIndex].Cells[5].Text; int pi = (ProfilesGrid.PageIndex * 20) + e.RowIndex; TextBox tb; if (this.ProfilesGrid.Rows.Count <= pi) { tb = (TextBox) this.ProfilesGrid.Rows[e.RowIndex].Cells[13].Controls[0]; } else{ tb = (TextBox) this.ProfilesGrid.Rows[pi].Cells[13].Controls[0]; } int id = (int)Convert.ToInt16(tb.Text.ToString()); //this.ProfilesGrid.Rows[pi].Cells[14] ) string SQL = "UPDATE People SET Deleted = 1 WHERE PersonID = " + id; // e.CommandArgument; Util.DoCmd(SQL); // pi -= 1; if (Session["dts"] != null) { DataSet dts = (DataSet)Session["dts"]; this.DeletedPersonRow = dts.Tables[0].NewRow(); //Save Person we're about to delete this.DeletedPersonRow.ItemArray = dts.Tables[0].Rows[pi].ItemArray; Session["DeletedPersonRow"] = this.DeletedPersonRow; this.DeletedRowIndex = pi; ViewState["DeletedRowIndex"] = this.DeletedRowIndex; dts.Tables[0].Rows[pi].Delete(); dts.AcceptChanges(); ProfilesGrid.DataSource = dts; ProfilesGrid.DataBind(); Session["dts"]= dts; } // 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 = id.ToString() ; // e.Keys["PersonID"].ToString(); UndoDel.CommandArgument = id.ToString();// e.Keys["PersonID"].ToString(); this.DisplayMessage("Removed " + PersonName + " click to "); //// } } else { clseditmode.dlt = false; } } /// <summary> /// Undelete a person /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void UndoDel_Click(object sender, EventArgs e) { LinkButton UndoDel = (LinkButton)sender; string SQL = "UPDATE People SET Deleted = 0 WHERE PersonID = " + UndoDel.CommandArgument; Util.DoCmd(SQL); clseditmode.personid = null; this.HideForms(sender, e); UndoDel.Visible = false; // Here we want to put saved DataRow into the dataset if (Session["DeletedPersonRow"] != null && Session["dts"] != null) { DataSet dts = (DataSet)Session["dts"]; DataRow dr = (DataRow) Session["DeletedPersonRow"]; dts.Tables[0].Rows.InsertAt(dr, (int)ViewState["DeletedRowIndex"]); dts.AcceptChanges(); Session.Remove("DeletedPersonRow") ; ViewState.Remove("DeletedRowIndex") ; Session["dts"] = dts; this.ProfilesGrid.DataBind(); } }More suggestions/critique are accepted with gratitude.