Example #1
0
 protected virtual void OnUpdateCommand(MxDataGridUpdateEventArgs e)
 {
     if (!(this.DataSource is DataControl) || ((DataControl) this.DataSource).CanUpdate)
     {
         this.OnBeforeUpdate(e);
         if (!e.Cancel)
         {
             int affectedRecords = 0;
             DataControl dataSource = (DataControl) this.DataSource;
             if (dataSource != null)
             {
                 if (dataSource.AutoGenerateUpdateCommand)
                 {
                     if (((this.DataKeys.Count == 0) || !this.AutoGenerateFields) || (this.AutoGenerateExcludeFields.Length > 0))
                     {
                         throw new HttpException(Microsoft.Matrix.Framework.SR.GetString("MxDataGrid_CantGenerateUpdateCommand"));
                     }
                     object obj2 = this.DataKeys[e.Item.ItemIndex];
                     Hashtable selectionFilters = new Hashtable();
                     Hashtable newValues = new Hashtable();
                     for (int i = this.fieldCollection.Count; i < e.Item.Cells.Count; i++)
                     {
                         if (e.Item.Cells[i].Controls.Count != 0)
                         {
                             TextBox box = (TextBox) e.Item.Cells[i].Controls[0];
                             if (box != null)
                             {
                                 newValues.Add(((Microsoft.Matrix.Framework.Web.UI.BoundField) this.autoGenFieldsArray[i - this.fieldCollection.Count]).DataField, box.Text);
                             }
                         }
                     }
                     selectionFilters.Add(this.DataKeyField, obj2);
                     affectedRecords = dataSource.Update(this.DataMember, selectionFilters, newValues);
                 }
                 else
                 {
                     affectedRecords = dataSource.Update(this.DataMember, e.SelectionFilter, e.NewValues);
                 }
                 this.EditItemIndex = -1;
             }
             if (this.AutoDataBind)
             {
                 this.DataBind();
             }
             this.OnAfterUpdate(new MxDataGridStatusEventArgs(e, affectedRecords));
         }
     }
 }
 public MxDataGridStatusEventArgs(MxDataGridUpdateEventArgs updateEventArgs, int affectedRecords)
 {
     this.item = updateEventArgs.Item;
     this.commandSource = updateEventArgs.CommandSource;
     this.affectedRecords = affectedRecords;
 }
Example #3
0
 protected virtual void OnBeforeUpdate(MxDataGridUpdateEventArgs e)
 {
     MxDataGridUpdateEventHandler handler = (MxDataGridUpdateEventHandler) base.Events[EventBeforeUpdate];
     if (handler != null)
     {
         handler(this, e);
     }
 }