If I want to add additional attributes to the current country dbf file, (ie., Sales numbers) can I add a field and reference it ? I tried to add a field and reference it with no luck.
Is this the correct thing to do or should I go down anohter path?
If I want to add additional attributes to the current country dbf file, (ie., Sales numbers) can I add a field and reference it ? I tried to add a field and reference it with no luck.
Is this the correct thing to do or should I go down anohter path?
George,
Thanks for your post!
Yes you can add a column to the current DBF File using the ShapeFileFeatureSource object. It allows you to add Columns and do other DBF operations if you need too. Here is the link to the wiki showing some of the Methods off of the ShapeFileFeatureSource:
wiki.thinkgeo.com/wiki/ThinkGeo.MapSuite.Core.ShapeFileFeatureSource
Your code may look something close to the code below:
ShapeFileFeatureLayer MyShapeFile = new ShapeFileFeatureLayer(“MyPath”);
ShapeFileFeatureSource MyShapeFileFeatureSource = (ShapeFileFeatureSource)MyShapeFile.FeatureSource;
MyShapeFileFeatureSource.AddColumnString(“Sales”, 50);
However if your sales data changes regularly and comes from some other source like a database I would recommend not adding a column to your shapefile but instead adding a custom column to your shapefile layer at run time. We gave a sample that shows this in the How Do I samples under the “Querying Feature Layers” section called “Add my own custom data to a feature layer”. While the sample doesn’t illustrate this very well what you would want to do under this scenario is to get a dataset from your external database that has the sales amount for each country, then in the custom column fetch routine you will check the current feature being processed and then add the column value for the sales amount. You will need to have a common piece of data between your dataset and the shapefile. This could be the country name or an id of some sort.
Please let us know if you have any questions on any of these items as we are here to help.
Thanks!
Thanks for the information.
Your welcome George, please let us know if you have any additional questions.
Thanks!