The editor can't save to database.

849
1
01-11-2012 07:39 AM
weiliang
New Contributor II
Hi,

I try to use the Editor to edit my feature layer (already versioned). All the binding button (i.e., Add, Select, Delete) works. But all the edit changes doesn't affect the database at all (I checked the SDE database). Our web services are secured, and I use proxy. What I did is:


1) Add an Editor to the Grid resources:
<esri:Editor x:Key="EditWellPadPolygon" Map="{Binding ElementName=MyMap}" LayerIDs="WetlandsDelinationArea" GeometryServiceUrl="http://ourwebsite/ArcGIS/rest/services/Geometry/GeometryServer"  EditCompleted="EditWellPadPolygon_EditCompleted"/>

2) Add the Feature layer to the map layers:
<esri:FeatureLayer ID="WetlandsDelinationArea" ProxyUrl="../proxy.ashx" Url="http://ourwebsite.com/ArcGIS/rest/services/Project/EcologyMobileProjects/FeatureServer/6" AutoSave="True" ValidateEdits="True" DisableClientCaching="True" Mode="OnDemand" Opacity="0.8" Visible="False" OutFields="*" InitializationFailed="MapServices_InitializationFailed"/>

3) Add an editing panel with all the buttons:
<StackPanel x:Name="editSP" Orientation="Vertical" VerticalAlignment="Stretch" DataContext="{StaticResource EditWellPadPolygon}">
    <Button Command="{Binding Add}" Content="1. Add New Record" ToolTipService.ToolTip="" Margin="14,0,14,5">
<Button.CommandParameter>
<sys:Int32>10101</sys:Int32>
</Button.CommandParameter>
</Button>
<Grid >
<Rectangle RadiusX="4" RadiusY="4" Margin="7,1,7,1" Stroke="Olive"></Rectangle>
<StackPanel Orientation="Vertical" VerticalAlignment="Stretch">
<Button Command="{Binding Select}" CommandParameter="New" Content="2. Select a Record to Delete" Margin="14,8,14,8"/>
<Button Command="{Binding ClearSelection}" Content="Clear Selection" Margin="28,2,14,8" Visibility="Collapsed"/>
<Button Command="{Binding DeleteSelected}" Content="Delete Selected Record" Margin="28,2,14,8" Visibility="Collapsed"/>
</StackPanel>
</Grid>
<Button Command="{Binding EditVertices}" Content="3. Change a Record Shape" Margin="14,5,14,5"/>
</StackPanel>

I don't think I need to code in the code behind. Correct me if I am wrong. To make sure this is not the problem, I added code in the code behind, but still doesn't work (I catched there is a Cancel action when I try to fire the add action. Don't know why.):
        private void EditWellPadPolygon_EditCompleted(object sender, ESRI.ArcGIS.Client.Editor.EditEventArgs e)
        {

            switch (e.Action)
            {
                case ESRI.ArcGIS.Client.Editor.EditAction.Add:
                    editEditor.Add.Execute(null);
                    break;
                case ESRI.ArcGIS.Client.Editor.EditAction.Save:
                    editEditor.Save.Execute(null);
                    break;   
                case ESRI.ArcGIS.Client.Editor.EditAction.DeleteSelected:
                    editEditor.DeleteSelected.Execute(null);
                    break;          
            }
        }

Many thanks for any help!

Wei
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
Can you subscribe to FeatureLayer.EndSaveEdits and SaveEditsFailed event? Do you get any error? You can run Fiddler to see monitor the web requests.

You are right that the code-behind snippet is not necessary, the buttons will activate on click because of the command binding. This code may also be the reason you are getting a cancel action. Activating a command (by click or code) will cancel previous command.
0 Kudos