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.

Regards
Fossi

//http://resources.esri.com/help/9.3/ArcGISDesktop/dotnet/2626201e-de60-4bab-bb1c-d16fcd4f8c4b.htm#NETFeature         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.             //http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Get_FeatureClass_of_Selected_Feature_Layer_in_Contents_View_Snippet/00490000004r000000/             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 = ArcMapHelperFunctions.app.FindExtensionByCLSID(editorUid) as ESRI.ArcGIS.Editor.IEditor3;              m_editor.StartEditing(editWorkspace);         }

Outcomes