Select to view content in your preferred language

How to get DisplayField property of layers which is binding to the map dynamically

858
1
02-09-2013 07:53 PM
abdulsharique
New Contributor
Hi All

I have a map where i am binding 5 layers at run time(dynamically). i just want to get the DisplayField value of all layers , and want to pass that value to the Query.where for feature search.

my code
if (MyMap.Layers.Count>0)
            {
                List<string> Ldisplay = new List<string>();
                for (int i = 0; i < MyMap.Layers.Count; i++)
                {
                        FeatureLayer myFeatureLayer = MyMap.Layers as FeatureLayer;
                        ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo myFeatureLayerInfo = myFeatureLayer.LayerInfo;
                        Ldisplay.Add(myFeatureLayerInfo.DisplayField.ToString());
                   
                }

its giving error "object reference not set to an instance of an object"
finally i have to search features dynamically based on DisplayField property of layer
please help .
Thank You
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
My best bet is that your map doesn't contain FeatureLayer only, so in your loop, myFeatureLayer can be null.
0 Kudos