<?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 set the Where clause for the FeatureLayer binded to a Feature Datagrid? in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96647#M2436</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Once the layer is added to the map, it gets initialized, you don't need to explicitly call Initialize(). You can subscribe to its Initialized event, if you need to do something right after the layer is initialized. In your code snippet though, you &lt;/SPAN&gt;&lt;STRONG&gt;don't need &lt;/STRONG&gt;&lt;SPAN&gt;to call Update() since it is the first time you are querying the service. If you will be updating Where clause again, check whether layer.IsInitialized before you call Update().&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Feb 2011 03:48:55 GMT</pubDate>
    <dc:creator>JenniferNery</dc:creator>
    <dc:date>2011-02-09T03:48:55Z</dc:date>
    <item>
      <title>How to set the Where clause for the FeatureLayer binded to a Feature Datagrid?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96640#M2429</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;BR /&gt;&lt;SPAN&gt;I have a FeatureLayer which is binded to a FeatureDatagrid, and I want to set the Where clause for this FeatureLayer in the code. How could I do this? The following is what I do now, but it seems doesn't work. Do I miss something?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; FeatureLayer GPgl2 = new FeatureLayer();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; GPgl2 = this.mainPage.MyMap.Layers["WellPermitsFL"] as FeatureLayer;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; GPgl2.Where = String.Format("{0}='{1}'", "Type", "Expired");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; GPgl2.Refresh();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your input.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wei&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Feb 2011 19:24:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96640#M2429</guid>
      <dc:creator>weiliang</dc:creator>
      <dc:date>2011-02-07T19:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to set the Where clause for the FeatureLayer binded to a Feature Datagrid?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96641#M2430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's your code with minor changes. You don't need to create a new instance of FeatureLayer and if you are changing parameters to your FeatureLayer query, you need to call Update() &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureLayer~Update.html" rel="nofollow"&gt;http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureLayer~Update.html&lt;/A&gt;&lt;SPAN&gt;. Refresh will redraw the current set of graphics.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;SPAN style="color:&amp;quot;red&amp;quot;;"&gt;//FeatureLayer GPgl2 = new FeatureLayer();&lt;/SPAN&gt; &lt;BR /&gt; &lt;SPAN style="color:&amp;quot;red&amp;quot;;"&gt;FeatureLayer&lt;/SPAN&gt; GPgl2 = this.mainPage.MyMap.Layers["WellPermitsFL"] as FeatureLayer;&amp;nbsp; &lt;BR /&gt;GPgl2.Where = String.Format("{0}='{1}'", "Type", "Expired");&amp;nbsp; &lt;BR /&gt;GPgl2&amp;nbsp; &lt;SPAN style="color:&amp;quot;red&amp;quot;;"&gt;.Update();&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Feb 2011 21:53:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96641#M2430</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2011-02-07T21:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to set the Where clause for the FeatureLayer binded to a Feature Datagrid?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96642#M2431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Many thanks, Jenifer. You resolved my problem. And I have another question about FeatureLayer. Can I dynamically add a FeatureLayer in the code rather than predefine in the .xaml?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to use the following code to fulfill this but failed (Error message: Object reference not set to an instance of an object.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My c# code is listed below, could someone check it for me? Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; FeatureLayer tempWellFL = new FeatureLayer();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; tempWellFL.Url = "gis.asdf.com/ArcGIS/rest/services/aaa/MapServer/0";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; this.mainPage.MyMap.Layers.Add(tempWellFL);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; tempWellFL.Update();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have a great day!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wei&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Feb 2011 16:18:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96642#M2431</guid>
      <dc:creator>weiliang</dc:creator>
      <dc:date>2011-02-08T16:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to set the Where clause for the FeatureLayer binded to a Feature Datagrid?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96643#M2432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Anything you can do in XAML, you can do in code-behind.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is close however I am curious with this line:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt;FeatureLayer tempWellFL = new FeatureLayer();&amp;nbsp;&amp;nbsp; &lt;BR /&gt;tempWellFL.Url = "gis.asdf.com/ArcGIS/rest/services/aaa/MapServer/0";&amp;nbsp; &lt;BR /&gt;this.&amp;nbsp; &lt;SPAN style="color:&amp;quot;blue&amp;quot;;"&gt;mainPage&lt;/SPAN&gt;.MyMap.Layers.Add(tempWellFL);&amp;nbsp; &lt;BR /&gt;//tempWellFL.Update();&amp;nbsp; &lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If MyMap is the name of your map, you can do MyMap.Layers.Add(tempWellFL). Maybe mainPage is null?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, you don't want to call Update() when there are no changes to the query and the layer has not been initialized.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Feb 2011 16:36:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96643#M2432</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2011-02-08T16:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to set the Where clause for the FeatureLayer binded to a Feature Datagrid?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96644#M2433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for you quick reply, Jennifer. I do want to use the update to reflect the Where clause (I deleted it to avoid the confusion). It is the featurelayer's update function shoot me error message. Before this line of code been executed, I can see that the featurelayer is been successfully added into the MyMap control. Any thoughts that why the update doesn't work? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW, if I use .xaml predefined FeatureLayer, there is no such problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;FeatureLayer tempWellFL = new FeatureLayer(); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tempWellFL.Url = "gis.asdf.com/ArcGIS/rest/services/aaa/MapServer/0";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;this.mainPage.MyMap.Layers.Add(tempWellFL);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tempWellFL.Where = "1=1";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tempWellFL.Update();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wei&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Feb 2011 17:15:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96644#M2433</guid>
      <dc:creator>weiliang</dc:creator>
      <dc:date>2011-02-08T17:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to set the Where clause for the FeatureLayer binded to a Feature Datagrid?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96645#M2434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The error is calling Update() before the layer is initialized. Since you are just adding the layer to your Map.Layers, the layer is not initialized yet. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, you don't need to call Update() if the Where clause is not changing. In your code, you are setting Where clause for the first time and don't need to call Update(). If you will&amp;nbsp; be changing Where clause later on and need to re-query the service, then you can call Update().&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Feb 2011 18:40:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96645#M2434</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2011-02-08T18:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to set the Where clause for the FeatureLayer binded to a Feature Datagrid?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96646#M2435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, Jennifer. So, how can I initialize this feature layer in the code?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Feb 2011 20:14:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96646#M2435</guid>
      <dc:creator>weiliang</dc:creator>
      <dc:date>2011-02-08T20:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to set the Where clause for the FeatureLayer binded to a Feature Datagrid?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96647#M2436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Once the layer is added to the map, it gets initialized, you don't need to explicitly call Initialize(). You can subscribe to its Initialized event, if you need to do something right after the layer is initialized. In your code snippet though, you &lt;/SPAN&gt;&lt;STRONG&gt;don't need &lt;/STRONG&gt;&lt;SPAN&gt;to call Update() since it is the first time you are querying the service. If you will be updating Where clause again, check whether layer.IsInitialized before you call Update().&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Feb 2011 03:48:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-set-the-where-clause-for-the-featurelayer/m-p/96647#M2436</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2011-02-09T03:48:55Z</dc:date>
    </item>
  </channel>
</rss>

