ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Editing Namespace / EditOperation Class / Modify Method / Modify(Row,String,Object) Method
The row to update.
The field name to update.
The new value.
Example

In This Topic
    Modify(Row,String,Object) Method
    In This Topic
    Modify a row, updating the attribute values. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void Modify( 
       Row row,
       string fieldName,
       object value
    )
    Public Overloads Sub Modify( _
       ByVal row As Row, _
       ByVal fieldName As String, _
       ByVal value As Object _
    ) 

    Parameters

    row
    The row to update.
    fieldName
    The field name to update.
    value
    The new value.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Order edits sequentially
    // perform an edit and then a split as one operation.
    QueuedTask.Run(() =>
    {
      var queryFilter = new QueryFilter();
      queryFilter.WhereClause = "OBJECTID = " + oid.ToString();
    
      // create an edit operation and name.
      var op = new EditOperation();
      op.Name = "modify followed by split";
      // set the ExecuteMOde
      op.ExecuteMode = ExecuteModeType.Sequential;
    
      using (var rowCursor = fc.Search(queryFilter, false))
      {
        while (rowCursor.MoveNext())
        {
          using (var feature = rowCursor.Current as Feature)
          {
            op.Modify(feature, "NAME", newName);
          }
        }
      }
    
      op.Split(layer, oid, splitLine);
      if (!op.IsEmpty)
      {
        bool result = op.Execute();
      }
      // else
      //  The operation doesn't make any changes to the database so if executed it will fail
    });
    Modify a record within Row Events - using EditOperation.Modify
    private void HookChangedEvent()
    {
      // subscribe to the RowChangedEvent
      Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault().GetTable();
      RowChangedEvent.Subscribe(MyRowChangedEvent, table);
    }
    
    private void MyRowChangedEvent(RowChangedEventArgs args)
    {
      // RowEvent callbacks are always called on the QueuedTask so there is no need 
      // to wrap your code within a QueuedTask.Run lambda.
    
      //example of modifying a field on a row that has been created
      var parentEditOp = args.Operation;
    
      // avoid recursion
      if (_lastEdit != args.Guid)
      {
        //update field on change
        parentEditOp.Modify(args.Row, "ZONING", "New");
    
        _lastEdit = args.Guid;
      }
    }
    Update Annotation Text via attribute. Caveat: The TEXTSTRING Anno attribute must exist
    //See "Change Annotation Text Graphic" for an alternative if TEXTSTRING is missing from the schema
    await QueuedTask.Run(() =>
    {
        //annoLayer is ~your~ Annotation layer...
    
        // use the inspector methodology
        var insp = new Inspector();
        insp.Load(annoLayer, oid);
    
        // make sure TextString attribute exists.
        //It is not guaranteed to be in the schema
        ArcGIS.Desktop.Editing.Attributes.Attribute att = insp.FirstOrDefault(a => a.FieldName == "TEXTSTRING");
        if (att != null)
        {
            insp["TEXTSTRING"] = "Hello World";
    
            //create and execute the edit operation
            EditOperation op = new EditOperation();
            op.Name = "Update annotation";
            op.Modify(insp);
    
            //OR using a Dictionary - again TEXTSTRING has to exist in the schema
            //Dictionary<string, object> newAtts = new Dictionary<string, object>();
            //newAtts.Add("TEXTSTRING", "hello world");
            //op.Modify(annoLayer, oid, newAtts);
    
            op.Execute();
        }
    });
    Edit the attributes of a FeatureSceneLayer
    //must support editing!
    var featSceneLayer = MapView.Active.Map.GetLayersAsFlattenedList()
                       .OfType<FeatureSceneLayer>().FirstOrDefault();
    if (!featSceneLayer.HasAssociatedFeatureService || 
        !featSceneLayer.IsEditable)
      return;
    
    var ok = await QueuedTask.Run(() =>
    {
      var editOp = new EditOperation()
      {
        Name = "Edit FeatureSceneLayer Attributes",
        SelectModifiedFeatures = true
      };
      //make an inspector
      var inspector = new Inspector();
      //get the attributes for the specified oid
      inspector.Load(featSceneLayer, oid);
      inspector["PermitNotes"] = "test";//modify
      editOp.Modify(inspector);
      return editOp.Execute();//synchronous flavor
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also