Select to view content in your preferred language

EndSaveEdits ... Graphics collection is empty after successfully adding!

2624
2
02-25-2014 03:01 PM
Labels (1)
michaelrosen
Deactivated User
I'm need to add rows that contain a FK into a primary table (wrapped by an ArcGISLocalFeatureLayer).  When I add the row into the primary table, everything indicates success in the EndSaveEdits ... but sometimes the the Graphics collection still shows empty.  Can someone offer some suggestions or insight?

            theFeatureLayer.EndSaveEdits += (s2, endEditEventArgs) =>
            {
              
                // I observe that after adding a row, sometimes  endEditEventArgs.Results.AddResults is 1 but theFeatureLayer.Graphics.Count is 0.  Why is that and what can I do about it?

                System.Diagnostics.Debug.Assert(theFeatureLayer == s2); // ok, as expected.

                if (endEditEventArgs.Results.AddResults != null)
                {
                    foreach (EditResultItem r in endEditEventArgs.Results.AddResults)
                    {
                        if (!r.Success)
                        { // no problem here...
                            theLogger.WriteLine(String.Format("EndSaveEdits skipped item due to '{0}'", r.ErrorDescription));
                            continue;
                        }
                        // Fails b/c the Graphics collection is empty.
                        Graphic gr = theFeatureLayer.Graphics.Single(g => (int)g.Attributes["OBJECTID"] == (int)r.ObjectID);
                        if (gr != null)
                        { // need to use the Graphic we just added.  If only it were available....
0 Kudos
2 Replies
Cristian_Galindo
Frequent Contributor
... but sometimes the the Graphics collection still shows empty.  Can someone offer some suggestions or insight?.


do you have any luck with this????
0 Kudos
Cristian_Galindo
Frequent Contributor
Hi,

read this post, I know it will help you:

http://forums.arcgis.com/threads/104530-Graphics-get-lost?p=373773&posted=1#post373773

You have to be aware of the layer's lifecycle:

first the layer must be created.....

Code:
var myLayer = new ArcGISLocalFeatureLayer(); // all code required to create it then initialize it

Code:
myLayer.Initialize(); ....and wait
When it finish to initialize (myLayer.Initialized event).....
you must update it

Code:
myLayer.Update(); .....and wait again...
When it finish to update (myLayer.UpdateCompleted event)....Voila!!!! you have your Graphics!!!
0 Kudos