Select to view content in your preferred language

How to modify the existing geometry

791
4
09-28-2011 06:58 PM
ivanlee
Emerging Contributor
FeatureLayer featureLayer =  mobileCache1.FeatureLayers["MyLayer"] as FeatureLayer;
    string whereClause = "Name like '%sky'";
    QueryFilter queryFilter = new QueryFilter(whereClause);
    try
    {
        FeatureDataTable featureDataTable = featureLayer.GetDataTable(queryFilter, null);
        int geometryColumnIndex = featureDataTable.GeometryColumnIndex;

        if (featureDataTable.Rows.Count > 0)
        {
            Polyline polyline = featureDataTable.Rows[0][geometryColumnIndex] as Polyline;
            polyline.Clear();
            polyline.AddPart(m_coordinateCollection);           
            int count = featureLayer.SaveEdits(featureDataTable);
            System.Diagnostics.Debug.WriteLine("Edit Count: " + count);          
        }
    }
    catch (Exception ex)
    {
        //throw ;
    }

    featureLayer.AllowNew is false
    featureLayer.AllowModify is true
    count is 0???
    help me,how to modify the polyline?
0 Kudos
4 Replies
StephenDickinson
Esri Contributor
Hi,

Try assigning the updated polyline back to the geometry object of the DataRow before calling featureLayer.SaveEdits(featureDataTable):

featureDataTable.Rows[0][geometryColumnIndex] = polyline;

Thanks,
Steve
0 Kudos
ivanlee
Emerging Contributor
Hi,

Try assigning the updated polyline back to the geometry object of the DataRow before calling featureLayer.SaveEdits(featureDataTable):

featureDataTable.Rows[0][geometryColumnIndex] = polyline;

Thanks,
Steve


Thank you,Steve.
When I do this "featureDataTable.Rows[0][geometryColumnIndex] = polyline;",
it throw an exception [System.Data.ReadOnlyException] = {"The Column �??SHAPE�?� is readonly�??"}
0 Kudos
StephenDickinson
Esri Contributor
Hi,

I've read your other related post too.

Just to confirm a few things:


  1. Are you using ArcGIS Mobile 10?

  2. Are you directly using the SDK or extending the out of the box application using the SDK?

  3. Is the layer in the cache from an SDE geodatabase?

  4. Has the GlobalID field been added to the source Feature Class using the ArcCatalog "Add Global IDs..." context menu option?


Thanks,
Steve
0 Kudos
ivanlee
Emerging Contributor
Hi,

I've read your other related post too.

Just to confirm a few things:


  1. Are you using ArcGIS Mobile 10?

  2. Are you directly using the SDK or extending the out of the box application using the SDK?

  3. Is the layer in the cache from an SDE geodatabase?

  4. Has the GlobalID field been added to the source Feature Class using the ArcCatalog "Add Global IDs..." context menu option?


Thanks,
Steve


Thank you , Steve.
Yes,I'm using ArcGis Moblie 10,and directly using the SDK.The layer is the SDE layer and has the GlobalID.
I try to delete the existing layer and add a new one, but the attribute FeatureDataTable.AllowNew is "false".
0 Kudos