I am currently wokring on ArcGIS API for Silverlight version 2.4. I working on the fcutnionaltiy of TRIM features where in the user can select the line feature to be trimmed, it does generate the result but it generates as a graphic, I am trying to replace that feature with the result graphic, but I am not able to do it.
Here is the code for that: protected void TrimEnd_Click(object sender, EventArgs e) { foreach (string layerID in featureLayerIDs) { FeatureLayer fLayer = this.MapControl.Layers[layerID] as FeatureLayer;
foreach (Graphic g in fLayer.SelectedGraphics) { if(g != null) { getFeatLayer = fLayer; MyDrawObject = new Draw(this.MapControl) { DrawMode = DrawMode.Polyline, IsEnabled = true, LineSymbol = this.Resources["NewLineSymbol"] as ESRI.ArcGIS.Client.Symbols.LineSymbol }; }
void GeometryService_TrimExtendCompleted(object sender, GraphicsEventArgs e) { //getFeatLayer.ClearGraphics(); Graphic resultGraphic = null; foreach (Graphic g in e.Results) { g.Symbol = this.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; resultGraphic = g; //getFeatLayer.Graphics.Add(g); GraphicsLayer TrimGraphicLyr = this.graphicsLayer as GraphicsLayer; //TrimGraphicLyr.ClearGraphics(); //TrimGraphicLyr.Graphics.Add(g); getFeatLayer.Graphics.Add(g); } foreach (Graphic g1 in getFeatLayer.SelectedGraphics) { //resultGraphic.Attributes.Add(g1.Attributes.ToArray());
foreach (var f in getFeatLayer.LayerInfo.Fields) { resultGraphic.Attributes[f.Name] = f.Nullable ? null : "testing"; }
getFeatLayer.Graphics.Remove(g1);
}
//Editor editor = LayoutRoot.Resources["MyEditor"] as Editor; foreach (GraphicsLayer graphicsLayer in featureEditor.GraphicsLayers) { if (graphicsLayer is FeatureLayer) { FeatureLayer featureLayer = graphicsLayer as FeatureLayer; if (featureLayer.HasEdits) featureLayer.Update(); featureLayer.SaveEditsFailed+=new EventHandler<TaskFailedEventArgs>(featureLayer_SaveEditsFailed); featureLayer.SaveEdits(); featureLayer.Refresh();
} }
MyDrawObject.IsEnabled = true; }
protected void featureLayer_SaveEditsFailed(object sender, EventArgs e) { } It thorws an error on saveedits failed with code 400- Unable to complete Operation, Unable to apply edits.
Does the datatypes you set in your attributes match the fields? Ie. string for string types, double for double types etc. Also there are read-only fields (like ObjectID) that you shouldn't be setting.