Select to view content in your preferred language

Can't Edit Attributes on the Fly

1876
6
12-09-2010 11:14 AM
AkhilParujanwala
Regular Contributor
Hi, I have a problem editing attributes of a feature class in ArcGIS Mobile.

I am going to try and simplify the explanation so bear with me.

I have successfully modified a feature's attribute while in the data collection process using code:
DataCollection_Complete - Eventhandler
Find the layer, modify a field in all the features in that layer and change it to a particular value.
fDataReader.SetValue(1,"Hello"); 
fDataReader.Update();

Then I use the Identify tool and identify any point on the map and that field will have "Hello".


The problem is I want to change the attribute value to Hello on a button click. For example:
Button1_Click();
Find the layer
Modify the field for all features in that layer and change it to a particular value.
fDataReader.SetValue(1,"Hello"); 
fDataReader.Update();

Then I use the Identify tool and identify any point on the map and that field will NOT have "Hello", it will be whatever it was before. Then I would close the application, load the application, Identify the point and now the field shows "Hello".

The problem is I had to close the application and open it again to see the new results.

As far as I can see, the cache receives the change to "Hello" for the attribute field but does not display it on the map, meaning some kind of refresh or invalidate would be needed to resolve this issue?

Note1: I can't use map1.Refresh or map1.Invalidate because I am using the Out-of-the-Box Tablet PC version.

Note2: I tried accessing the storage cache and using map.AddRange(mobileCache1) after the fDataReader.Update() but that still didn't work.

Note3: I have simplified the problem but there really is a button click event that will trigger a change in the attribute value of a particular feature class. I don't want to have to close the app and open the app just to see the change.

Please help me if you can.

Thanks,

Akhil P.
0 Kudos
6 Replies
AkhilParujanwala
Regular Contributor
Ok I have solved it, but it is very weird as to why this works and not the other, have a look below.

1) This works
using (FeatureDataReader fDataReader = featureLayer.GetDataReader(pQFilter))
            {
                while (fDataReader.Read())
                {
                    fDataReader.SetValue(colEventIndex, txtEvent.Text);
                    fDataReader.SetValue(colDevicesIndex, txtBarcodes.Text);
                }
                fDataReader.Update();
            }


2) Does not work

 // queries the datatable and prepares it to be read from 
            FeatureDataReader fDataReader = featureLayer.GetDataReader(pQFilter);
            //ESRI.ArcGIS.Mobile.Client.Windows.MessageBox.ShowDialog(fDataReader.GetDataTypeName(columnNameIndex));
            // allows the datatable to be read
            fDataReader.Read();

            // sets the current event and radiation devices to the team's info
            fDataReader.SetValue(colEventIndex, txtEvent.Text);
            fDataReader.SetValue(colDevicesIndex, txtBarcodes.Text);           

            fDataReader.Update();     


Notice the subtle difference? One is looping the other is not looping. The interesting thing is I have code elsewhere that is not using a loop and yet it works. ArcGIS Mobile is picky 😛

Thanks,

Akhil P.
0 Kudos
dingleonardo
Emerging Contributor
thanks for your note!
i am a new man on the road of arcgis mobile learning
having seen your note, i know that you can help me to slove a problem
1,when i want to edit the layer  in the emulator , the message will show that "it can not be edited"
2,can i new a layer in the emulator ?

expecting your reply
0 Kudos
AkhilParujanwala
Regular Contributor
I have replied in your thread.
0 Kudos
dingleonardo
Emerging Contributor
I have replied in your thread.


I cannot thank you enough for your reply!!
i have added the globle ids,but it can not work
just like the code:
private void menuItemSave_Click(object sender, EventArgs e)
{
ESRI.ArcGIS.Mobile.MobileServices.FeatureLayer featureLayer = this.mobileService1.Layers[2] as ESRI.ArcGIS.Mobile.MobileServices.FeatureLayer;
if (featureLayer.AllowNew)
{
......
}
}

the featurelayer.allownew is also false
how can i do now?
0 Kudos
dingleonardo
Emerging Contributor
do you have QQ or email
i can send my project to you
0 Kudos
dingleonardo
Emerging Contributor
i guess that  it may relate with my data


personal geodatabase    ,name is    NorthAmerica
map document              ,name is    NorthAmerica
0 Kudos