<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to get graphic attribute values in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558910#M14373</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;That should work. Might be there is a blank or a special character in your key.&lt;BR /&gt;&lt;BR /&gt;Could you check with this code which for sure will use the right name:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// How to get at graphic attributes
foreach (var a in g.Attributes)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; //MessageBox.Show(a.Key + ":&amp;nbsp;&amp;nbsp; " + a.Value);
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (a.Value != g.Attributes[a.Key])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show("Strange error here: " + a.Key);
}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Dom. Unfortunately your sample provides no new insight. I have also tried this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
foreach (var a in gr.Attributes)
{
&amp;nbsp; MessageBox.Show(a.Key + ":&amp;nbsp;&amp;nbsp; " + a.Value);
&amp;nbsp; if (a.Key == "PAGsde.DBO.TrafficCountNetwork.OBJECTID")
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID = a.Value as string;
&amp;nbsp;&amp;nbsp; }
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;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?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 00:07:28 GMT</pubDate>
    <dc:creator>DonFreeman</dc:creator>
    <dc:date>2021-12-12T00:07:28Z</dc:date>
    <item>
      <title>How to get graphic attribute values</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558908#M14371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi -&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;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?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp; foreach (Graphic g in featureSet.Features)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Graphic gr = featureSet.Features[0];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g.Symbol = LayoutRoot.Resources["LinesSymbol"] as LineSymbol;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphicsLayer.Graphics.Add(g);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID = g.Attributes["PAGsde.DBO.TrafficCountNetwork.OBJECTID"] as string;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // How to get at graphic attributes
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //foreach (var a in g.Attributes)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show(a.Key + ":&amp;nbsp;&amp;nbsp; " + a.Value);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The loop which is commented out reveals that the key "PAGsde.DBO.TrafficCountNetwork.OBJECTID" is a valid key with a value but ID always comes up null. How can I assign the key value to the variable?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Dec 2012 21:10:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558908#M14371</guid>
      <dc:creator>DonFreeman</dc:creator>
      <dc:date>2012-12-10T21:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to get graphic attribute values</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558909#M14372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;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?&lt;BR /&gt; I have the following:&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;That should work. Might be there is a blank or a special character in your key.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you check with this code which for sure will use the right name:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// How to get at graphic attributes
foreach (var a in g.Attributes)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; //MessageBox.Show(a.Key + ":&amp;nbsp;&amp;nbsp; " + a.Value);
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (a.Value != g.Attributes[a.Key])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show("Strange error here: " + a.Key);
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:07:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558909#M14372</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2021-12-12T00:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get graphic attribute values</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558910#M14373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;That should work. Might be there is a blank or a special character in your key.&lt;BR /&gt;&lt;BR /&gt;Could you check with this code which for sure will use the right name:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// How to get at graphic attributes
foreach (var a in g.Attributes)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; //MessageBox.Show(a.Key + ":&amp;nbsp;&amp;nbsp; " + a.Value);
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (a.Value != g.Attributes[a.Key])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show("Strange error here: " + a.Key);
}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Dom. Unfortunately your sample provides no new insight. I have also tried this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
foreach (var a in gr.Attributes)
{
&amp;nbsp; MessageBox.Show(a.Key + ":&amp;nbsp;&amp;nbsp; " + a.Value);
&amp;nbsp; if (a.Key == "PAGsde.DBO.TrafficCountNetwork.OBJECTID")
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID = a.Value as string;
&amp;nbsp;&amp;nbsp; }
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;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?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:07:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558910#M14373</guid>
      <dc:creator>DonFreeman</dc:creator>
      <dc:date>2021-12-12T00:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to get graphic attribute values</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558911#M14374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;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?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Likely your value is not a string so casting it to string returns null.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Try: ID = a.Value.ToString(); instead.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2012 21:06:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558911#M14374</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2012-12-12T21:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to get graphic attribute values</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558912#M14375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Dom. That solved the problem. I didn't realize there was a difference between the two syntaxes. However the bad news is I was chasing the wrong rabbit. I am trying to fix some code someone else wrote and frankly I don't understand it all that well.&amp;nbsp; The actual problem has to do with a relationship query. This code :&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Int32 MyVar = Convert.ToInt32(g.Attributes[SelectedRoadsTreeView.Tag as string]);

RelationshipParameter relationshipParameters = new RelationshipParameter()
{
&amp;nbsp; ObjectIds = new int[] { Convert.ToInt32(g.Attributes[SelectedRoadsTreeView.Tag as string]) },
&amp;nbsp; OutFields = new string[] { "loc_id, count_id, _year, adt" },
&amp;nbsp; RelationshipId = 0,
&amp;nbsp; OutSpatialReference = Map.SpatialReference
};
queryTask.ExecuteRelationshipQueryAsync(relationshipParameters);
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;fails when it runs with a message that there are missing or invalid parameters. The first line verifies that there is a valid objectid (739 in my case). The service that it is accessing is &lt;/SPAN&gt;&lt;A href="http://gismaps.pagnet.org/arcgis/rest/services/tempTrafficcounts/MapServer/0" rel="nofollow noopener noreferrer" target="_blank"&gt;http://gismaps.pagnet.org/arcgis/rest/services/tempTrafficcounts/MapServer/0&lt;/A&gt;&lt;SPAN&gt;. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you suggest what might be wrong? The problem may be with the service since the original was destroyed and we tried to recreate it. Perhaps I need something structured differently there? Thanks for any help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:07:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558912#M14375</guid>
      <dc:creator>DonFreeman</dc:creator>
      <dc:date>2021-12-12T00:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to get graphic attribute values</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558913#M14376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your feature layer doesn't allow querying on related data. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you look at this working sample : &lt;/SPAN&gt;&lt;A href="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0"&gt;http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp; you'll notice the 2 relationships to 'Tops' and 'Fields', and the 'Query Related Records' URL at the botton of the page.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your service has not these capabilities.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Dec 2012 14:22:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558913#M14376</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2012-12-13T14:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to get graphic attribute values</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558914#M14377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Your feature layer doesn't allow querying on related data. &lt;BR /&gt;&lt;BR /&gt;If you look at this working sample : &lt;A href="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0"&gt;http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0&lt;/A&gt;&amp;nbsp; you'll notice the 2 relationships to 'Tops' and 'Fields', and the 'Query Related Records' URL at the botton of the page.&lt;BR /&gt;&lt;BR /&gt;Your service has not these capabilities.&lt;BR /&gt;&lt;BR /&gt;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.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you, thank you, thank you. After thinking about it more I suspected the problem was with the service. We had all joins and no relates. That simple suggestion took care of it. Problem solved!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Dec 2012 16:19:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-get-graphic-attribute-values/m-p/558914#M14377</guid>
      <dc:creator>DonFreeman</dc:creator>
      <dc:date>2012-12-13T16:19:00Z</dc:date>
    </item>
  </channel>
</rss>

