Select to view content in your preferred language

Explicit save; feat layer added in C#code; could not save changes.

861
2
Jump to solution
09-21-2012 02:10 PM
Ravichandran_M_Kaushika
Regular Contributor
dear Readers,

thanks for taking the time to read through this post.

In order to minimize web traffic,  I was thinking about using explicit save as indicated in the link below:
http://resources.arcgis.com/en/help/silverlight-api/samples/start.htm#EditToolsExplicitSave - it should be noted that in the example, url for the feature layer was set in XAML when the editor was defined.

for situations when the url has to changed outside by admin, i had to implement using the URL from web.config and setting the feature layer in code behind and added it as a single item in layerlist <lst> to .LayerIDs member of the editor.  this point feature service was set up with geom changes allowed mode.

when i made the changes and clicked the save button <Button command="{Binding Save}" ..../> did not commit the changes to the feat layer. so to find out whether whether there was  set up problem in the POINT feat layer with feature layer /0 entered in XAML and its layer id entered into LayerList string and IT WORKED. it committed the changes to the server when layerids are defined in XAML when editor is declared.

to force save, i found this code and thought it might work =

Editor editor = LayoutRoot.Resources["MyEditor"] as Editor;
            foreach (GraphicsLayer graphicsLayer in editor.GraphicsLayers)
            {
                if (graphicsLayer is FeatureLayer)
                {
                    FeatureLayer featureLayer = graphicsLayer as FeatureLayer;
                    if (featureLayer.HasEdits)
                        featureLayer.Update();
                }
            }

in that for each, editor.GraphicsLayers was empty and it exited the loop.

so when we are adding the LayerIDs in C# code (or vb.net), it does not do all the magic that setting LayerIDs in XAML does.  if tech team can identify those extra magic, then we can add in C# code.

thanks and regards
ravi.
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
if (featureLayer.HasEdits)
featureLayer.Update();

You should call SaveEdits instead of Update.
Update reloads graphics at client side by taking care of changes that may have been done at server side.
It's not saving anything at server side.

View solution in original post

0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
if (featureLayer.HasEdits)
featureLayer.Update();

You should call SaveEdits instead of Update.
Update reloads graphics at client side by taking care of changes that may have been done at server side.
It's not saving anything at server side.
0 Kudos
Ravichandran_M_Kaushika
Regular Contributor
Dominique,

good morning.  thanks a lot for promptly. 

your code fixed it - further, there was a name conflict in my layer list that caused the issue.

i will mark your reply as solving the issue.

your 2 answers improved my application issues to a great extent.

thanks a lot.

regards
ravichandran.
0 Kudos