var id = graphic.Attributes[layer.LayerInfo.ObjectIdField];
Kindly refer to this documentation: http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureSer...
If LayerInfo is retrieved after the layer has initialized so be sure to check that layer.LayerInfo is not null.
The following code retrieves the feature ID:var id = graphic.Attributes[layer.LayerInfo.ObjectIdField];
Public ReadOnly Property ObjectIdField As Stringdoesn't tell me anything about how to make the assignment. Something like this is needed.
Graphic g = new Graphic() { // set Geometry property from ShapeFile. } var objectId; // retrieve from DBF file (?) g.Attributes["objectid"] = objectId; // to save object id onto an attribute field var oid = g.Attributes["objectid']; // to retrieve the object id from an attribute field.
I'm sorry I have more questions than answers. I wanted to know how you load shapefiles to your map? Does it have a corresponding .dbf that holds the attributes of the feature? I imagine that this is where you'd keep record of the object ID.
How you create and save the object ID is important to know because it also dictates how you can retrieve them. You can use the graphic's Attributes to hold this information (http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Graphic~At...).
It says that this is read-only property meaning you cannot create a new instance, but you can update the existing instance. You can do something like:Graphic g = new Graphic() { // set Geometry property from ShapeFile. } var objectId; // retrieve from DBF file (?) g.Attributes["objectid"] = objectId; // to save object id onto an attribute field var oid = g.Attributes["objectid']; // to retrieve the object id from an attribute field.
Note that in this example, I just used "objectid" as my key for the field. You can name this as you wish but be mindful that the key you used to save is the same key you need to use to retrieve.
Shapefile is actually an unfamiliar territory for me but I found some links that might be useful for your project.
http://esrislcontrib.codeplex.com/
http://forums.arcgis.com/threads/6425-Export-to-shapefile-other-format
http://forums.arcgis.com/threads/13680-Download-Shapefiles-Similar-to-the-Extract-Service-in-ArcIMS
Other developers are welcome to provide additional help 🙂
<!--<esri:Map x:Name="MyMap" Grid.RowSpan="2" > <esri:Map.Layers> <esri:ArcGISDynamicMapServiceLayer ID="Intersections" Url="http://198.182.104.173/ArcGIS/rest/services/Intersection_Test/MapServer" /> </esri:Map.Layers> </esri:Map> -->In this case its a point layer. What I want to do is click a point and capture the FID for that point so I can use it to query a separate but related table.
Just to be clear: The Client APIs does not support working with Shapefiles. You will need to publish your data to ArcGIS Server first. After that, it doesn't' really matter how the data is stored as long as it is server out using ArcGIS Server. When you are at that point, you will be using a FeatureLayer as Jennifer was getting at.