How to Remove Features from ArcGIS online using C#

3267
2
Jump to solution
09-16-2014 04:37 AM
JessicaLott
New Contributor III

I use ArcGIS online and the ArcGIS Runtime for WPF products. I am able to add and edit features perfectly fine from code, however I can not delete them from code. I also can remove them from the Datagrid and manually through ArcGIS online.

 

The code I am currently is below:

 

 

private void RemoveQueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)

        {

            FeatureLayer featurelayerSO = MyMap.Layers["ServiceOrders"] as FeatureLayer;

            FeatureSet featureSet = args.FeatureSet;

            try

            {

                if (featureSet.Features.Count > 0)

                {

                    featurelayerSO.Graphics.Remove(featureSet.Features[0]);

                    featurelayerSO.SaveEdits();

                    featurelayerSO.Update();

                }

                else

                {

                    MessageBox.Show("No features found");

                }

 

            }

            catch (Exception e)

            {

                MessageBox.Show(e.Message);

            }

        }

 

When I step through this code, all of the values are showing as they should. The featureSet.Features[0] is exactly what I want it to be.. Any help would be appreciated. I am sure there is something simple I am missing.

 

Attached is a photo of the supported operations.

0 Kudos
1 Solution

Accepted Solutions
JessicaLott
New Contributor III

I was able to get this to work by using RemoveAt(ObjectID) instead of Remove(Graphic). I am going out on a limb and saying that it may be because the graphic in the featureset is not actually the graphic in the feature layer...?

View solution in original post

0 Kudos
2 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

I suggest taking a look at the Dev Summit examples: http://www.arcgis.com/home/item.html?id=3f69c79bbd7340b09fad396647a977a5

Specifically the Editing-Stand-Alone-Tables example.

Cheers

Mike

0 Kudos
JessicaLott
New Contributor III

I was able to get this to work by using RemoveAt(ObjectID) instead of Remove(Graphic). I am going out on a limb and saying that it may be because the graphic in the featureset is not actually the graphic in the feature layer...?

View solution in original post

0 Kudos