protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { int i = ASPxGridView1.FindVisibleIndexByKeyValue(e.Keys[ASPxGridView1.KeyFieldName]); Control c = ASPxGridView1.FindDetailRowTemplateControl(i, "ASPxGridView2"); e.Cancel = true; ds = (DataSet)Session["DataSet"]; ds.Tables[0].Rows.Remove(ds.Tables[0].Rows.Find(e.Keys[ASPxGridView1.KeyFieldName])); }
protected void ASPxTreeList1_FocusedNodeChanged(object sender, EventArgs e) { object key = ASPxTreeList1.FocusedNode.Key; if (key != null) { ASPxGridView1.FocusedRowIndex = ASPxGridView1.FindVisibleIndexByKeyValue(key); } }
protected string GetDetailRowValue(string id) { var index = ASPxGridView1.FindVisibleIndexByKeyValue(id); var detail = ASPxGridView1.FindDetailRowTemplateControl(index, "ASPxGridViewDetail") as ASPxGridView; if (detail != null) { return(detail.FindVisibleIndexByKeyValue(id).ToString()); } return(string.Empty); }
protected void ASPxGridView1_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) { int productCode = Convert.ToInt32(e.Parameters); ShoppingCartStorage.AddToCart(productCode); ASPxGridView1.DataBind(); int addedRowIndex = ASPxGridView1.FindVisibleIndexByKeyValue(productCode); ASPxGridView1.ScrollToVisibleIndexOnClient = addedRowIndex; ASPxGridView1.FocusedRowIndex = addedRowIndex; }
protected string GetDetailRenderedControlID(string keyvalue, string controlId) { if (string.IsNullOrEmpty(controlId)) { return(string.Empty); } var index = ASPxGridView1.FindVisibleIndexByKeyValue(keyvalue); var detail = ASPxGridView1.FindDetailRowTemplateControl(index, "ASPxGridViewDetail") as ASPxGridView; var control = detail.FindEditFormTemplateControl(controlId); return(control.ClientID); }
/// <summary> /// http://demos.devexpress.com/ASPxGridViewDemos/GridEditing/Validation.aspx /// if (e.NewValues["FirstName"] != null && e.NewValues["FirstName"].ToString().Length /// AddError(e.Errors, grid.Columns["Categoria"], grid.Columns["Categoria"].Caption + ": El valor ya existe con otro registro..."); /// TIP: si el campo esta invisible, e.NewValues devuelve NULL /// </summary> protected void ASPxGridView1_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { /* * if (ASPxGridView1.IsNewRowEditing && e.NewValues["UserPass"] == null) * { * AddError(e.Errors, ASPxGridView1.Columns["UserPass"], ASPxGridView1.Columns["UserPass"].Caption + ": Escriba una contraseña."); * } */ string tsql = ""; // validar valores contra DB // TIP: si el campo esta invisible, e.NewValues devuelve NULL // http://devexpress.com/Support/Center/p/Q109251.aspx if (e.NewValues["Shareholding"] != null) { int Id = 0; int currentIndex = 0; if (e.Keys.Count > 0) { currentIndex = ASPxGridView1.FindVisibleIndexByKeyValue(e.Keys[0]); } object IdvalGrid = ASPxGridView1.GetRowValues(currentIndex, "ID"); if (IdvalGrid != null) { Id = Convert.ToInt32(IdvalGrid); } SqlParameter[] paramsToSP = { new SqlParameter("@Shareholding", e.NewValues["Shareholding"].ToString()) , new SqlParameter("@RowID", Id) }; if (e.IsNewRow) // insert { tsql = "SELECT SUM([Shareholding]) + @Shareholding FROM [dbo].[Organizations]"; } else // update { tsql = "SELECT SUM([Shareholding]) + @Shareholding FROM [dbo].[Organizations] WHERE ID != @RowID"; } int?codigo = SqlApiSqlClient.GetIntRecordValue(tsql, paramsToSP, Global.Configuration.DB.GetConnectionStringDBMain()); if (codigo != null) { if (codigo > 100) { AddError(e.Errors, ASPxGridView1.Columns["Shareholding"], ASPxGridView1.Columns["Shareholding"].Caption + ": Con este valor sobrepasa el 100%..."); } } } if (string.IsNullOrEmpty(e.RowError) && e.Errors.Count > 0) { e.RowError = "Por favor corrija los errores."; } }
/// <summary> /// http://demos.devexpress.com/ASPxGridViewDemos/GridEditing/Validation.aspx /// if (e.NewValues["FirstName"] != null && e.NewValues["FirstName"].ToString().Length /// AddError(e.Errors, grid.Columns["Categoria"], grid.Columns["Categoria"].Caption + ": El valor ya existe con otro registro..."); /// TIP: si el campo esta invisible, e.NewValues devuelve NULL /// <2></2></summary> protected void grid_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { /* * if (ASPxGridView1.IsNewRowEditing && e.NewValues["UserPass"] == null) * { * AddError(e.Errors, ASPxGridView1.Columns["UserPass"], ASPxGridView1.Columns["UserPass"].Caption + ": Escriba una contraseña."); * } */ string tsql = ""; // validar valores contra DB // TIP: si el campo esta invisible, e.NewValues devuelve NULL // http://devexpress.com/Support/Center/p/Q109251.aspx if (e.NewValues["UserLogin"] != null) { int Id = 0; int currentIndex = 0; if (e.Keys.Count > 0) { currentIndex = ASPxGridView1.FindVisibleIndexByKeyValue(e.Keys[0]); } object IdvalGrid = ASPxGridView1.GetRowValues(currentIndex, "UserId"); if (IdvalGrid != null) { Id = Convert.ToInt32(IdvalGrid); } SqlParameter[] paramsToSP = { new SqlParameter("@UserLogin", e.NewValues["UserLogin"].ToString()) , new SqlParameter("@UserId", Id) }; if (e.IsNewRow) // insert { tsql = "SELECT UserId FROM [User] WHERE UserLogin = @UserLogin"; } else // update { tsql = "SELECT UserId FROM [User] WHERE UserLogin = @UserLogin AND UserId != @UserId"; } int?codigo = SqlApiSqlClient.GetIntRecordValue(tsql, paramsToSP, Global.DAL.GetConnectionStringDBData()); if (codigo != null) { AddError(e.Errors, ASPxGridView1.Columns["UserLogin"], ASPxGridView1.Columns["UserLogin"].Caption + ": El valor ya existe con otro registro..."); } } if (string.IsNullOrEmpty(e.RowError) && e.Errors.Count > 0) { e.RowError = "Por favor corrija los errores."; } }