Exemplo n.º 1
0
    protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
    {
        ASPxGridView    gridView = sender as ASPxGridView;
        ASPxHiddenField hfData   = gridView.FindTitleTemplateControl("hfData") as ASPxHiddenField;

        OleDbConnection connection = GetConnection();

        if (connection == null)
        {
            return;
        }

        for (int i = 0; i < gridView.VisibleRowCount; i++)
        {
            bool     isRowUpdated = false;
            object[] values       = new object[gridView.Columns.Count];
            foreach (GridViewDataColumn column in gridView.Columns)
            {
                string fieldKey = String.Format("{0}_{1}", gridView.GetRowValues(i, gridView.KeyFieldName), column.FieldName);
                if (hfData.Contains(fieldKey))
                {
                    values[column.Index] = hfData[fieldKey];
                    isRowUpdated         = true;
                }
                else
                {
                    values[column.Index] = gridView.GetRowValues(i, column.FieldName);
                }
            }
            if (isRowUpdated)
            {
                UpdateGrid(connection, gridView, values);
            }
        }
        connection.Close();
        gridView.DataBind();
    }