Displaying FiledAliases instead of DisplayFieldName

755
1
02-15-2013 11:38 AM
srikanthpilli
New Contributor II
Hello,

Could you please provide your suggestions on it.


When I click on the feature on a map - it should display the "FieldAliases" of the layer instead of "DisplayFieldName". And there is a property for the featurset -"FieldAliases" - but I am not sure how I can convert the Dictionary<string,string> to string datatype.

Please find below the code for this:

#region GeoFeatureCollection Class - Equivalent to FeatureSet
    public class GeoFeatureCollection : ObservableCollection<Graphic>
    {
        private string _outputFields = "";
        private string _outputLabels = "";
        private string _displayField = "";
        private string _featureLayer = "";
        private string _dataSourceName = "";
        private string _hyperlinkField = "";
        private GeometryType _geometryType;
        private string _fieldaliases = "";


        #region Properties
        public string OutputFields
        {
            get { return this._outputFields; }
            set { this._outputFields = value; }
        }

        public string OutputLabels
        {
            get { return this._outputLabels; }
            set { this._outputLabels = value; }
        }

        public string DisplayFieldName
        {
            get { return this._displayField; }
            set { this._displayField = value; }
        }


        public string FieldAliases
        {
            get { return this._fieldaliases; }
            set { this._fieldaliases = value; }
        }
      
        public string FeatureLayerName
        {
            get { return this._featureLayer; }
            set { this._featureLayer = value; }
        }

        public string DataSourceName
        {
            get { return this._dataSourceName; }
            set { this._dataSourceName = value; }
        }

        public string HyperlinkField
        {
            get { return this._hyperlinkField; }
            set { this._hyperlinkField = value; }
        }

        public GeometryType GeometryType
        {
            get { return this._geometryType; }
            set { this._geometryType = value; }
        }
        #endregion

        public GeoFeatureCollection()
        {
        }

        public GeoFeatureCollection(FeatureSet fset, string featureLayerName) : this(fset, "", "", featureLayerName) { }

        public GeoFeatureCollection(FeatureSet fset, string outputFields, string outputLabels, string featureLayerName)
        {
            this._outputFields = outputFields;
            this._outputLabels = outputLabels;
            this._featureLayer = featureLayerName;
            this._geometryType = fset.GeometryType;
            this._displayField = fset.DisplayFieldName;
           

this._fieldaliases = fset.FieldAliases; (This is the line of the code for which I m getting the below message)

"Cannot implicitly convert type 'System.Collections.Generic.Dictionary<string,string>' to 'string'"         


            foreach (Graphic graphic in fset.Features)
            {
                graphic.Geometry.SpatialReference = fset.SpatialReference;
                this.Add(graphic);
            }
        }


Thanks in Advance for providing your inputs.
0 Kudos
1 Reply
PhilipKnight1
Occasional Contributor
The FieldAliases is a dictionary. I would suggest looking up what a dicitonary is for a better explanation, but essentially you pass it a key/string and it will return an value/string (or object if defined as so). Most likely you want to pass it the FieldName you want the alias of and it should return that alias.
0 Kudos