Select to view content in your preferred language

Create New - Table - Feature Layer

797
2
11-01-2011 12:26 PM
AjaySisodia2
Emerging Contributor
Hello:

Does anybody know how create a new feature/record in a table published as the feature layer.

I have a layer and few associated tables published all as feature layers and I want to create a new record in the associated table when a new feature is created in the map.

Thanks alot in advance.
ajay -
0 Kudos
2 Replies
ChristopherHill
Deactivated User
Create a new Graphic and populate the Graphic.Attributes dictionary with the values, then add the graphic to your featurelayer. If AutoSave = true on you feature layer the graphic will be pushed back to your table. If AutoSave = false on your feature layer you will have to call FeatureLayer.SaveEdits()

Example:
Say your table has two fields, FirstName (text) and Age(integer).

your graphic would look like this.

Graphic graphic = new Graphic()
graphic.Attributes.Add("FirstName","John");
graphic.Attributes.Add("Age", 25);

MyFeatureLayer.Graphics.Add(graphic)
MyFeatureLayer.SaveEdits() // <-- only need if MyFeatureLayer.AutoSave = false;
0 Kudos
AjaySisodia2
Emerging Contributor
Thanks very much for the tip and the sample code Chris, i appreciate it. let me try this approach.

Ajay -
0 Kudos