Select to view content in your preferred language

Feature Layer query after editing

2305
3
02-28-2011 10:26 AM
WilliamKimrey
Emerging Contributor
Hello all,

After I perform an edit on a  FeatureLayer, when I query the feature I just edited, the query results return the old value.  This doesn't happen when I add a new feature, only when I edit an existing feature.  Any reason why this is or ideas on how to get the new updated values?

Thanks,
Will
0 Kudos
3 Replies
WilliamKimrey
Emerging Contributor
I should probably clarify that the QueryTask I'm using is on the MapService while the editing is on the FeatureService for the same published MXD.  I get the feeling that this is where the disconnect lies.

Thanks,
Will
0 Kudos
JenniferNery
Esri Regular Contributor
I tried to replicate the issue by performing an attribute value change on feature service and performing a query on its corresponding map service after the edit was submitted to the server. I was able to see the updated attribute value when my QueryTask ExecuteCompleted.

I used the following code where my FeatureLayer is AutoSave=True so I did not need to call SaveEdits() explicitly. I also subscribed to EndSaveEdits and SaveEditsFailed to make sure that the edit was submitted to the server.
private void Query_Click(object sender, RoutedEventArgs e)
{
 Query q = new Query()
 {
  OutFields = new OutFields() { "*" },
  ObjectIDs = new int[] { 78597 },
 };    
 QueryTask qt = new QueryTask("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer/2");
 qt.DisableClientCaching = true;
 qt.ExecuteCompleted += new EventHandler<QueryEventArgs>(qt_ExecuteCompleted);
 qt.ExecuteAsync(q);
}

void qt_ExecuteCompleted(object sender, QueryEventArgs e)
{
 foreach (var f in e.FeatureSet.Features)
  System.Diagnostics.Debug.WriteLine(f.Attributes["description"]);
}

private void FeatureLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs e)
{
 //78597
 e.Graphic.Attributes["description"] = "this is a test";
}


If SaveEditsFailed event did not get raised and the edit was submitted successfully, maybe you just need to set DisableClientCaching to true on QueryTask http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Tasks.Task...
0 Kudos
WilliamKimrey
Emerging Contributor
Thanks Jennifer,

Setting DisableClientCaching to true solved the problem.  I'm not getting the correct updated values for my query.  Thank you for the solution.

Will
0 Kudos