Select to view content in your preferred language

Editing attributes not using the editor widget

745
3
10-12-2010 12:19 PM
IvanGibson
Deactivated User
Hi,

I'm new to both silverlight and esri. I need to be able to edit attributes of existing points through code rather than using editor widget. How would i go about doing this, or where would be a good starting point to learn about this?
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
Each graphic have Attributes property which is of type Dictionary<string, object>. You can easily observe what the values are by doing:
foreach(var item in graphic.Attributes)
   MessageBox.Show(string.Format("{0}: {1}", item.Key, item.Value));

To know the field type, you can go to FeatureLayer.LayerInfo.Fields. Each field will tell you if it is Editable, if it has Length restriction, and what type it falls under. You can check out the API Reference tab, specifically this: http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Field_memb...

You should then be able to do something like to edit a certain attribute.
graphic.Attributes["fieldName"] = fieldValue; //where fieldValue matches the type of "fieldName"
0 Kudos
dotMorten_esri
Esri Notable Contributor
Just to add to that: FeatureLayer automatically tracks changes to its graphics collection, and the attributes and geometry of the individual graphics. If it detects a change, it will automatically get pushed back to the server.
So like Jennifer wrote, all you need to do is:
graphic.Attributes["fieldName"] = myFieldValue;
0 Kudos
IvanGibson
Deactivated User
Many thanks to the both of you for your help! we have it working now
0 Kudos