<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Feature's HasOID is false, values are empty in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/feature-s-hasoid-is-false-values-are-empty/m-p/97378#M2573</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for sharing this information.&amp;nbsp; I had the exact same problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Jul 2015 20:15:17 GMT</pubDate>
    <dc:creator>TedRakel</dc:creator>
    <dc:date>2015-07-07T20:15:17Z</dc:date>
    <item>
      <title>Feature's HasOID is false, values are empty</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/feature-s-hasoid-is-false-values-are-empty/m-p/97376#M2571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to get a value of a particular field from selected features. The features are from a layer that contains data from a file geodatabase. The data has been imported from an excel spreasheet, the file geodatabase is set as the default geodatabase and the feature class appears to be registered with it (the "Register with Geodatabase" option in the Manage menu is disabled).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I obtain &lt;EM&gt;IEnumFeature &lt;/EM&gt; from the focused map's &lt;EM&gt;FeatureSelection:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;IMap map = ArcMap.Document.ActiveView.FocusMap;
IEnumFeature ftEnum = map.FeatureSelection as IEnumFeature;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then have a while loop that fetches selected features from the enum and tries to get a particular field value:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;IFeature ft = null;

while ((ft = ftEnum.Next()) != null) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; int fid = ft.Fields.FindField("LOCODE");
&amp;nbsp;&amp;nbsp;&amp;nbsp; string locode = ft.get_Value(fid) as string;
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, the fid gets correctly assigned to 1, which is the index of the "LOCODE" field, but the returned value is null. I noticed that the features do not have OID associated with them. Why is that? If I export the feature class as a shapefile and add it to the map, the OIDs are set. But the "LOCODE" values are missing in either case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why is this happening?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:06:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/feature-s-hasoid-is-false-values-are-empty/m-p/97376#M2571</guid>
      <dc:creator>DavidStefan</dc:creator>
      <dc:date>2021-12-11T06:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Feature's HasOID is false, values are empty</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/feature-s-hasoid-is-false-values-are-empty/m-p/97377#M2572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, here's a solution. Looping over the &lt;EM&gt;IEnumFeature&lt;/EM&gt; doesn't ensure that all fields are returned, apparently. In my case this resulted in NO field values being returned, including the OID which was missing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have managed to get the fields by setting the &lt;EM&gt;AllFields&lt;/EM&gt; of the &lt;EM&gt;IEnumFeatureSetup&lt;/EM&gt; to &lt;EM&gt;true&lt;/EM&gt;. Code below illustrates the solution, hope this helps someone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;IMxDocument doc = ArcMap.Application.Document as IMxDocument;
IMap map = doc.FocusMap;

// Retrieve selected features enum
IEnumFeature ftEnum = map.FeatureSelection as IEnumFeature;
IEnumFeatureSetup ftSetup = (IEnumFeatureSetup)ftEnum;

// Make sure ALL fields are returned
ftSetup.AllFields = true;

ftEnum.Reset();
IFeature ft;

while ((ft = ftEnum.Next()) != null) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; int fldID = ft.Fields.FindField("LOCODE");
&amp;nbsp;&amp;nbsp;&amp;nbsp; message += ft.get_Value(fldID) + "\n";
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:06:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/feature-s-hasoid-is-false-values-are-empty/m-p/97377#M2572</guid>
      <dc:creator>DavidStefan</dc:creator>
      <dc:date>2021-12-11T06:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Feature's HasOID is false, values are empty</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/feature-s-hasoid-is-false-values-are-empty/m-p/97378#M2573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for sharing this information.&amp;nbsp; I had the exact same problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 20:15:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/feature-s-hasoid-is-false-values-are-empty/m-p/97378#M2573</guid>
      <dc:creator>TedRakel</dc:creator>
      <dc:date>2015-07-07T20:15:17Z</dc:date>
    </item>
  </channel>
</rss>

