foreach (Graphic g in featureSet.Features) { //Graphic gr = featureSet.Features[0]; g.Symbol = LayoutRoot.Resources["LinesSymbol"] as LineSymbol; graphicsLayer.Graphics.Add(g); ID = g.Attributes["PAGsde.DBO.TrafficCountNetwork.OBJECTID"] as string; // How to get at graphic attributes //foreach (var a in g.Attributes) //{ // MessageBox.Show(a.Key + ": " + a.Value); //} }
Your feature layer doesn't allow querying on related data. If you look at this working sample : http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0 you'll notice the 2 relationships to 'Tops' and 'Fields', and the 'Query Related Records' URL at the botton of the page.Your service has not these capabilities.To allow querying on related data, you must defined a Relationship in your geodatabase and your published map document must contain the 2 layers or tables involved in the Relationship class.
Int32 MyVar = Convert.ToInt32(g.Attributes[SelectedRoadsTreeView.Tag as string]); RelationshipParameter relationshipParameters = new RelationshipParameter() { ObjectIds = new int[] { Convert.ToInt32(g.Attributes[SelectedRoadsTreeView.Tag as string]) }, OutFields = new string[] { "loc_id, count_id, _year, adt" }, RelationshipId = 0, OutSpatialReference = Map.SpatialReference }; queryTask.ExecuteRelationshipQueryAsync(relationshipParameters);
When this loop runs, the if statement finds true one time and executes the assignment, but the value of ID remains null. The messagebox however shows a value of 739. I just don't get it and am totally frustrated. Can you think of anything else?
That should work. Might be there is a blank or a special character in your key.Could you check with this code which for sure will use the right name: // How to get at graphic attributes foreach (var a in g.Attributes) { //MessageBox.Show(a.Key + ": " + a.Value); if (a.Value != g.Attributes[a.Key]) MessageBox.Show("Strange error here: " + a.Key); }
// How to get at graphic attributes foreach (var a in g.Attributes) { //MessageBox.Show(a.Key + ": " + a.Value); if (a.Value != g.Attributes[a.Key]) MessageBox.Show("Strange error here: " + a.Key); }
foreach (var a in gr.Attributes) { MessageBox.Show(a.Key + ": " + a.Value); if (a.Key == "PAGsde.DBO.TrafficCountNetwork.OBJECTID") { ID = a.Value as string; } }
I thought I knew this but I guess I don't. Given a graphic with attributes, how do you obtain the value of a specific attribute key? I have the following:
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.