<?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 problem setting FeatureLayer Where property at run time in code behind in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99846#M2499</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi - My app includes a feature layer. The app starts with all features in the layer shown. Later, I give the user a chance to restrict the features to a particular set, I do this by resetting the layer's Where property in a method in the code-behind, like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;FeatureLayer siteLayer = Map.Layers["Sites"] as FeatureLayer;
siteLayer.Where = "PROPERTY_ID = 123";&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This should cause all but one feature to disappear from the map. But nothing happens, the map appears unchanged.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Seeing &lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=213&amp;amp;f=2455&amp;amp;t=299876" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.esri.com/Thread.asp?c=213&amp;amp;f=2455&amp;amp;t=299876&lt;/A&gt;&lt;SPAN&gt; I add another line:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;siteLayer.Update();&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This causes all features in the map to be cleared. Further, If I try to do anything else in this method with the siteLayer reference (like get its extent so I can zoom to it), I now get a null reference exception.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see from &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/40125-Is-there-a-feature-layer-quot-completed-quot-event" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/40125-Is-there-a-feature-layer-quot-completed-quot-event&lt;/A&gt;&lt;SPAN&gt; that maybe I should wait to interact with the layer again until that event fires. It doesn't explain however why I either get no change in my map, or all my features disappear.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also see the developer in that second post is doing something like removing and readding the layer. Is that necessary in my case, seems odd?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MC&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 06:12:16 GMT</pubDate>
    <dc:creator>markcheyne</dc:creator>
    <dc:date>2021-12-11T06:12:16Z</dc:date>
    <item>
      <title>problem setting FeatureLayer Where property at run time in code behind</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99846#M2499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi - My app includes a feature layer. The app starts with all features in the layer shown. Later, I give the user a chance to restrict the features to a particular set, I do this by resetting the layer's Where property in a method in the code-behind, like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;FeatureLayer siteLayer = Map.Layers["Sites"] as FeatureLayer;
siteLayer.Where = "PROPERTY_ID = 123";&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This should cause all but one feature to disappear from the map. But nothing happens, the map appears unchanged.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Seeing &lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=213&amp;amp;f=2455&amp;amp;t=299876" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.esri.com/Thread.asp?c=213&amp;amp;f=2455&amp;amp;t=299876&lt;/A&gt;&lt;SPAN&gt; I add another line:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;siteLayer.Update();&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This causes all features in the map to be cleared. Further, If I try to do anything else in this method with the siteLayer reference (like get its extent so I can zoom to it), I now get a null reference exception.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see from &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/40125-Is-there-a-feature-layer-quot-completed-quot-event" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/40125-Is-there-a-feature-layer-quot-completed-quot-event&lt;/A&gt;&lt;SPAN&gt; that maybe I should wait to interact with the layer again until that event fires. It doesn't explain however why I either get no change in my map, or all my features disappear.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also see the developer in that second post is doing something like removing and readding the layer. Is that necessary in my case, seems odd?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MC&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:12:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99846#M2499</guid>
      <dc:creator>markcheyne</dc:creator>
      <dc:date>2021-12-11T06:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: problem setting FeatureLayer Where property at run time in code behind</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99847#M2500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;It doesn't explain however why I either get no change in my map, &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;That's normal. You need to call Update after changing the Where clause. 'Update' will reexecute the request.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt;or all my features disappear.&lt;BR /&gt; &lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't explain either, except obviously if your request returns nothing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you sure that your criteria "PROPERTY_ID = 123" is supposed to return something?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can test your query directly in your browser or use fiddler to look at the request sent, that should give a clue.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2011 07:03:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99847#M2500</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2011-12-08T07:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: problem setting FeatureLayer Where property at run time in code behind</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99848#M2501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I really appreciate the feedback, thank you. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;New day, fresh mind, I've got it sorted. Turns out I had a bug elsewhere. FYI, this is all that is necessary to immediately make the map filter its visible contents to the desired features:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;FeatureLayer siteLayer = Map.Layers["Sites"] as FeatureLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;siteLayer.Where = "PROPERTY_ID = 123";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;siteLayer.Update();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, MC&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2011 12:51:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99848#M2501</guid>
      <dc:creator>markcheyne</dc:creator>
      <dc:date>2011-12-08T12:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: problem setting FeatureLayer Where property at run time in code behind</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99849#M2502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Strange!!.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My best bet at this time is that your where clause is not working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you use fiddler to look at the request sent?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Also could you try with a where clause 100% garantee such as "1=1"?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tested with the Feature Layers Simple sample.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I execute these lines of code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp; var featureLayer = MyMap.Layers["MyFeatureLayer"] as FeatureLayer;
&amp;nbsp;&amp;nbsp; featureLayer.Where = "POP1990 &amp;gt; 50000";
&amp;nbsp;&amp;nbsp; featureLayer.Update();
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;a new request is sent to the server and more cities are displayed (initial criteria was &amp;gt; 100000).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Note : I just noticed I had inversed 'Refresh' and 'Update' in my previous post. I fixed that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:12:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99849#M2502</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2021-12-11T06:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: problem setting FeatureLayer Where property at run time in code behind</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99850#M2503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to do this same thing and every time I run my map It displays nothing. The code I am using is.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;FeatureLayer siteLayer = MyMap.Layers["Dispatch"] as FeatureLayer;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; siteLayer.Where = "Status = Complete";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; siteLayer.Update();&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My goal is actually to display everything that is not complete so I also tried&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;FeatureLayer siteLayer = MyMap.Layers["Dispatch"] as FeatureLayer;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; siteLayer.Where = "Status &amp;lt;&amp;gt; Complete";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; siteLayer.Update();&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Neither of these work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also tried adding a where clause on the MainPage.xaml&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;esri:FeatureLayer&amp;nbsp; DisableClientCaching="True" Where="Status = Complete" ID="Dispatch"&amp;nbsp;&amp;nbsp; OutFields="*" x:Name="Dispatch"&amp;nbsp; MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp" Mode="OnDemand"&amp;nbsp;&amp;nbsp; SelectionColor="Cyan"&amp;nbsp;&amp;nbsp; Visible="True" Url="http://gis02/ArcGIS/rest/services/FeatureServices/Dispatch/FeatureServer/0"/&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This also did not work, It gave me a blank map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any advice on this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jerry&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:12:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99850#M2503</guid>
      <dc:creator>JerryBiedenbender</dc:creator>
      <dc:date>2021-12-11T06:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: problem setting FeatureLayer Where property at run time in code behind</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99851#M2504</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;jerry - your experience seems to suggest problems with the Where expression? While I was troubleshooting, if I put my Where expression into the layer's XAML, I'd see what I wanted. Maybe confirm in ArcMap that your Where expression works on that layer?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, try removing the DisableClientCaching property, and set the layer Mode to "Snapshot"?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2011 15:38:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99851#M2504</guid>
      <dc:creator>markcheyne</dc:creator>
      <dc:date>2011-12-09T15:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: problem setting FeatureLayer Where property at run time in code behind</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99852#M2505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I figured it out, I had a coded domain set up on my layer and it wanted the number value instead of the text value&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2011 16:44:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-featurelayer-where-property-at-run/m-p/99852#M2505</guid>
      <dc:creator>JerryBiedenbender</dc:creator>
      <dc:date>2011-12-09T16:44:01Z</dc:date>
    </item>
  </channel>
</rss>

