Select to view content in your preferred language

FeatureLayer SaveEdits error

677
3
08-30-2011 09:26 AM
ThomasDobrzinski1
Emerging Contributor
Hi,
I try to add points to my FeatureLayer. Unfortunately the FeatureLayer doesn´t recognize the Edits and I don´t know why

foreach (var fl in OMap.Layers)
     {
      if (fl is ESRI.ArcGIS.Client.FeatureLayer)
      {
       if ((fl as ESRI.ArcGIS.Client.FeatureLayer).Url == "http://.../myFeatureLayer/FeatureServer/0")
       {
        oFeatureLayer = fl as ESRI.ArcGIS.Client.FeatureLayer;
       }
      }
     }


     ESRI.ArcGIS.Client.Geometry.MapPoint mp = new ESRI.ArcGIS.Client.Geometry.MapPoint(X, Y);

     Graphic graphic = new Graphic();

     graphic.Geometry = mp;
     graphic.Attributes.Add("guid", g);
     
     oFeatureLayer.Graphics.Add(graphic);
     if (oFeatureLayer.HasEdits)
     {
     oFeatureLayer.SaveEdits();
     }


What´s wrong with it? Do have have to initialize the FeatureLayer? Any ideas?
best regards and many thanks !
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
Try to run fiddler and/or subscribe to SaveEditsFailed/EndSaveEdits events. There could be required attributes that you are not setting or attribute value type had a mismatch.

You can follow the same troubleshooting steps in this blog post: http://blogs.esri.com/Dev/blogs/silverlightwpf/archive/2009/08/24/Troubleshooting-blank-layers.aspx
0 Kudos
wangzhifang
Frequent Contributor
Always double check your graphic�??s attributes. If there is something wrong, such as format doesn't match on serverside, SaveEdits() will do nothing.
0 Kudos
ThomasDobrzinski1
Emerging Contributor
Hi,
thank you for your replies.
The error is:

graphic.Attributes.Add("guid", g);


When adding the attribute "guid" to the feature the error occurs.
"guid" is an esri guid field, the g was created with
System.Guid g;
g = (Guid.NewGuid());

Are there any special features that can go wrong?

The add of a feature without giving the attributes works fine.

Thanks again !
best regards

SOLVED:

It was an error with the guid, the "{", "}" were needed...
0 Kudos