theFeatureDataGrid.Map = null; theFeatureDataGrid.GraphicsLayer = null; ESRI.ArcGIS.Client.FeatureLayer fl = theMap.Layers["flyr_RoadClosureLocations"] as ESRI.ArcGIS.Client.FeatureLayer; foreach (ESRI.ArcGIS.Client.Graphic g in fl.Graphics) { if (g.Attributes["UPID"].ToString() == "CAB_035") { g.Attributes["UPDATEDATE"] = null; } } theFeatureDataGrid.Map = theMap; theFeatureDataGrid.GraphicsLayer = fl;
You are right, by default DateField has a default length of 36.You can try the following feature service that has a nullable DateField. Setting the attribute value to null does not raise any exception. You can wire up to EndSaveEdits and SaveEditsFailed to see that this new value is actually saved. FeatureLayer layer = new FeatureLayer() { Url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/0", OutFields = new ESRI.ArcGIS.Client.Tasks.OutFields() { "*" } }; layer.Initialized += (s,e) => { layer.Update(); }; layer.UpdateCompleted += (s,e) => { var graphic = layer.Graphics.FirstOrDefault(g => (int)g.Attributes["objectid"] == 105635); graphic.Attributes["collection_time"] = null; }; layer.Initialize(); If you are still experiencing issues please explain your use case with details about the data and application workflow so we can reproduce it here. Thanks.
FeatureLayer layer = new FeatureLayer() { Url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/0", OutFields = new ESRI.ArcGIS.Client.Tasks.OutFields() { "*" } }; layer.Initialized += (s,e) => { layer.Update(); }; layer.UpdateCompleted += (s,e) => { var graphic = layer.Graphics.FirstOrDefault(g => (int)g.Attributes["objectid"] == 105635); graphic.Attributes["collection_time"] = null; }; layer.Initialize();
ESRI.ArcGIS.Client.FeatureLayer fl = theMap.Layers["flyr_RoadClosureLocations"] as ESRI.ArcGIS.Client.FeatureLayer; foreach (ESRI.ArcGIS.Client.Graphic g in fl.Graphics) { if (g.Attributes["UPID"].ToString() == "CAB_035") { MessageBox.Show(g.Attributes["UPDATEDATE"].ToString()); g.Attributes["UPDATEDATE"] = null; } }
g. Attributes["UPDATEDATE"] = null
I guess DateTime is Non-Nullable DataType so setting it to null won't work.Try setting it to null as follows:g.Attributes["UPDATEDATE"] = new DateTime?();
g.Attributes["UPDATEDATE"] = null
I think that since you gave a length requirement, a validation exception will be thrown if this is not met. If you made g.Attributes["UPDATEDATE"] = null. If you remove this length requirement, I think you should be able to set it to a null value without validation exception.
Graphic.Attributes["DateField"] = null should work. Are you saying it doesn't? It not, what happens when you try that?
foreach (ESRI.ArcGIS.Client.Graphic g in fl.Graphics) { if ((int)g.Attributes["OBJECTID"] == objid) { IDictionary<string, object> att = g.Attributes; if (att["UPDATETIME"] != null) { att["UPDATETIME"] = ""; } if (att["UPDATEDATE"] != null) { //UpdateDate is a Date field att["UPDATEDATE"] = null; } if (att["DESCRIPTION"] != null) { att["DESCRIPTION"] = ""; } } }
UPDATEDATE (Type: esriFieldTypeDate, Alias: UPDATEDATE, Length: 36, Editable: True)
collection_time (Type: esriFieldTypeDate, Alias: Collection Date, Length: 36, Editable: True)
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.