AnsweredAssumed Answered

Start editing programmatically - how to get the workspace to edit?

Question asked by Fossi on May 15, 2014
Latest reply on May 19, 2014 by Fossi
Hello experts,

when trying to start an edit session programmatically I am a little stuck with the workspace to edit.
Everything works fine, as long as I use feature classes belonging to a feature dataset. But as soon as I use a standalone feature class the featureDataset attribute (see code below) becomes null (of course).

Is it just bad practice to have standalone feature classes? Or is there another way, to obtain the right edit workspace?

Thanks in advance, any hint is appreciated.


//         private void startEditing(ESRI.ArcGIS.Framework.IApplication ArcMap)         {             ESRI.ArcGIS.Geodatabase.IFeatureClass m_featureClass;             ESRI.ArcGIS.Editor.IEditor m_editor;              ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)ArcMap.Document;             ESRI.ArcGIS.ArcMapUI.IContentsView curTOC = mxDocument.CurrentContentsView;             //Create a method to get a reference to the feature class or add the ArcGIS Desktop snippet.             //             m_featureClass = ArcMapHelperFunctions.GetFeatureClassOfSelectedFeatureLayerInContentsView(curTOC);              //Once the feature class has been referenced, get the workspace to edit by creating an IFeatureWorkspace             //and setting an IWorkspace object to the feature workspace using a cast.              ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featWork = m_featureClass.FeatureDataset.Workspace as ESRI.ArcGIS.Geodatabase.IFeatureWorkspace;              ESRI.ArcGIS.Geodatabase.IWorkspace editWorkspace = featWork as ESRI.ArcGIS.Geodatabase.IWorkspace;              //Start an edit session on the workspace holding the feature class, which must be in a feature dataset.             ESRI.ArcGIS.esriSystem.UID editorUid = new ESRI.ArcGIS.esriSystem.UID();             editorUid.Value = "esriEditor.Editor";             m_editor = as ESRI.ArcGIS.Editor.IEditor3;              m_editor.StartEditing(editWorkspace);         }