protected void grid_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { ASPxGridView grid = sender as ASPxGridView; DataTable table = new DataTable(); if (Convert.ToInt32(Request.QueryString["id"].ToString()) > 0) { EmpTS emp = new EmpTS(); table = emp.getByProductID(Convert.ToInt32(Request.QueryString["id"].ToString())); DataColumn colid = table.Columns[0]; table.PrimaryKey = new DataColumn[] { colid }; } else { table = GetTable(); } DataRow found = table.Rows.Find(e.Keys[0]); found["ItemName"] = e.NewValues["ItemName"]; found["ItemOrder"] = e.NewValues["ItemOrder"]; Session["Table"] = table; grid.DataSource = table; grid.DataBind(); e.Cancel = true; grid.CancelEdit(); }
protected void Page_Init(object sender, EventArgs e) { if (IsPostBack) { if (Session["Table1"] != null) { Session["Table"] = Session["Table1"]; grid.DataSource = GetTable(); grid.KeyFieldName = "EmpTimeSheetID"; grid.DataBind(); } } if (!IsPostBack) { if (Request.QueryString["alert"] == "notpass") { Response.Write("<script>alert('لم يتم الحفظ');</script>"); } Session["Table1"] = null; Session["Table"] = null; if (Convert.ToInt32(Request.QueryString["id"].ToString()) > 0) { EmpTS emp = new EmpTS(); DataTable dt = emp.getByProductID(Convert.ToInt32(Request.QueryString["id"].ToString())); grid.DataSource = dt; grid.KeyFieldName = "EmpTimeSheetID"; grid.DataBind(); btnEdit.Visible = true; btnSave.Visible = false; DataColumn colid = dt.Columns["EmpTimeSheetID"]; dt.PrimaryKey = new DataColumn[] { colid }; colid.ReadOnly = true; Session["Table"] = dt; } else { grid.DataSource = GetTable(); grid.KeyFieldName = "EmpTimeSheetID"; grid.DataBind(); } } }