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].Rows[pi]; //Save Person we're about to delete 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 ");