Select to view content in your preferred language

How to get a map layer's attribute values in a stand-alone mobile app?

3067
4
09-15-2010 06:41 AM
TanjaKantola
Emerging Contributor
I am developing a stand-alone application with Mobile SDK 9.3.1. The application does not use a database.

How could I list the values of a certain map layer's attribute (table row values) in my application?
I am using a locally stored mapcache. I am able to retrieve the names of the attributes (column names) with the following piece of code:

ESRI.ArcGIS.Mobile.MobileServices.FeatureLayer layer = this.mobileService.Layers[0] as ESRI.ArcGIS.Mobile.MobileServices.FeatureLayer;
DataTable table = layer.GetDataTable();
foreach (DataColumn column in table.Columns)
Debug.WriteLine(column.ToString());

However, I have not been able to get the rows of the columns and their content data with table.Rows.
Also, table.Rows.Count returns 0, even though the attribute table does have values (checked with ArcMap), and the corresponding items are displayed on the mobile map.

What am I doing wrong?
0 Kudos
4 Replies
MelindaFrost
Frequent Contributor
I had the same issue. When I sent in a blank new queryfilter it worked. Try:
DataTable table = layer.GetDataTable(new QueryFilter);
0 Kudos
AngelGonzalez
Frequent Contributor
Instead of using:

DataTable table = layer.GetDataTable(); use FeatureDataTable table = layer.GetDataTable();

then assign it as the source of your datagrid:

dataGridView1.DataSource = table;
0 Kudos
MaximilianGlas
Esri Contributor
I had the same issue. When I sent in a blank new queryfilter it worked. Try:
DataTable table = layer.GetDataTable(new QueryFilter);


Or you use a null parameter to get all data:
FeatureDataTable table = layer.GetDataTable(null);


For not selecting all data it is good to use the QueryFilter
QueryFilter queryFilter1 = new QueryFilter(string.Format("ID = {0} AND JAHR = {1}", id, jahr), true);
FeatureDataTable table = layer.GetDataTable(queryFilter1);


For selecting data by geometry:
QueryFilter queryFilter2 = new QueryFilter();
queryFilter2.Geometry = _aktGeom.GetExtent();
queryFilter2.GeometricRelationship = GeometricRelationshipType.Intersect;
FeatureDataTable table = layer.GetDataTable(queryFilter2);
0 Kudos
TanjaKantola
Emerging Contributor
Hi!

Thank you all for the replies! They helped to solve the issue 🙂
0 Kudos