ThinkGeo.com    |     Documentation    |     Premium Support

Adding new columns in shape file and give values in all rows of those columns

Hello everyone,



I want to add 2 extra columns in a InMemoryFeatureLayer in a controller and  also add values in all rows of those additional columns.


FeatureLayer shapeFileLayer = (FeatureLayer)((LayerOverlay)map.CustomOverlays[“StaticOverlay”]).Layers[“DivisionLayer”];
            InMemoryFeatureLayer mapShapeLayer = (InMemoryFeatureLayer)((LayerOverlay)map.CustomOverlays[“HightLightDynamicOverlay”]).Layers[“HighLightLayer2”];
            mapShapeLayer.IsVisible = true;
            shapeFileLayer.Open();
            Collection<Feature> features = shapeFileLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);
            shapeFileLayer.Close();
            mapShapeLayer.InternalFeatures.Clear();
//here i want to add all columns in shapeFileLayer to mapShapeLayer
            foreach (Feature feature in features)
            {
                mapShapeLayer.InternalFeatures.Add(feature.Id, feature);
            }
//Now i want to add 2 extra columns and give them values from a database table.
//Don’t worry about data and its type I Just want to know how it can be possible.

If there is some way to add a temporary columns in shape file please give me its sample or code.

Thanks.

Hi Shehraz, 
  
 I think you can view this sample, it should be helpful: 
  
 Sample "Hook Up External Data to Shapefile" in wiki.thinkgeo.com/wiki/map_suite_wpf_desktop_edition_all_samples 
  
 Regards, 
  
 Don