Select to view content in your preferred language

Programatically selecting querytask results in FeatureLayer.

2703
3
09-20-2010 06:51 PM
KevinSchumm
Emerging Contributor
I was wondering if there was a way to run a QueryTask and then programatically select the results of that task in a feature layer.

I haven't been able to programatically select any features in a featurelayer.

Thanks.
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
You can set IsSelected property for each graphic returned by the QueryTask. Note that for SelectionOnly mode, you need to add each selected graphic to the layer and save edits before the selected features are added to the server.
0 Kudos
KevinSchumm
Emerging Contributor
Thanks for your response Jennifer.

Maybe I'm approaching this wrong. Let me explain the situation and see what your thoughts are.

I have a featurelayer on my map that is showing points. I present the user with a search window that allows them to search for a feature in that layer based on some attributes. I am using a QueryTask to get the features from the server that match those attributes.

I now have a FeatureSet that I'm displaying to the user in a datagrid. I want the user to be be able to click that row, have the map pan/zoom to that feature in the featurelayer that is already turned on, and also programmatically select that feature for the user.

I've tried setting "selected" to true on the graphics that return from the QueryTask, but this doesn't seem to tie back to the graphics in the FeatureLayer already displaying on the map.
0 Kudos
JenniferNery
Esri Regular Contributor
Have you tried using the FeatureDataGrid?  http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureDataGrid The FeatureDataGrid has FilterSource property which is an IEnumerable<Graphic>. You can set this with the QueryTask results. You can also set AutoZoomToSelected to achieve what you want to happen on row selection.
0 Kudos