EditorWidget FeatureDataForm events and when can save edits

3266
1
12-15-2011 11:14 PM
JudyTroutwine
Occasional Contributor
I need to refine when some code is run in response to an attribute change value in a FeatureDataForm.  I am trying to capture a changed attribute value in a form right click event procedure.  Apparently the layer edits must first be saved to get the new value.  However the feature layer SaveEdits() method seems to have no effect when used in the right click event procedure.  The section of code for this is shown below (gChange is global).

      private void fdform_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {

           if (fdform.HasEdits)
            {
                object src = e.OriginalSource;  //returns the border for the form, can also get position relative to particular UI elements
                FeatureLayer featureLayer = gChange.Layer as FeatureLayer;
                featureLayer.SaveEdits();         //seems to have no effect
                string val1 = editFeat.Attributes["Common_Name"].ToString();  // "unknown"
                string val2 = String.Copy("unknown");   //to avoid being saved in the same memory location as var1
                bool blnIsEqual = val1.Equals(val2, StringComparison.Ordinal);
                ...
   
I would ideally like to save edits temporarily and undo them to allow the user to save a feature when done editing of that feature.

(Although using the Graphic.AttributeValueChanged procedure is effective in some ways, the timing is after the user presses the SaveEdits button on the EditorWidget.)
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
If FeatureLayer.AutoSave is True (this is default setting), FeatureLayer.SaveEdits() will not have any bearing in your app since edits are committed (submitted to server) immediately.

If you want to make saving explicit, set AutoSave=False. You don't have much control over FeatureDataForm from EditorWidget though. Instead you can use FeatureDataForm outside EditorWidget: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitFeatureDataForm. You can subscribe to FeatureDataForm.EndEdits instead of Graphic.AttributeValueChanged. EndEdits fires when apply button is clicked. You can call layer.SaveEdits() then.
0 Kudos