Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have :

  • FeatureClass (Structure)
  • column (Type)
  • column (OID)

I am trying to get the (Type) for specific OID. I tried to use this code but it dose not work.

IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
IFeatureClass testFeatureClass = featureWorkspace.OpenFeatureClass("Structure");
IQueryFilter queryFilter = new QueryFilterClass();
queryFilter.SubFields = "Type";
queryFilter.WhereClause = "OBJECTID = " + feature.OID;
IFeatureCursor fCursor = testFeatureClass.Search(queryFilter, true);

I don't know what is the wrong, any help would be appreciated.

share|improve this question
Can you elaborate on "does not work"? Exception? Zero features in the cursor? Feature has no data value for the field? – Jay Cummins Jun 19 '12 at 10:02
up vote 3 down vote accepted

You can get field value by doing the following. 1. Select your feature. 2. Cursor through feature to see if selection set is > 1 (below is code example for step 2).

IFeatureSelection pFSel = default(IFeatureSelection);
pFSel = pFLayer;
ESRI.ArcGIS.Geodatabase.ISelectionSet2 pSelSet = default(ESRI.ArcGIS.Geodatabase.ISelectionSet2);
pSelSet = pFSel.SelectionSet;
if (pSelSet.Count < 1) {
    MsgBox("No Features Selected")

ESRI.ArcGIS.Geodatabase.IFeatureCursor pFCursor = null;
pSelSet.Search(null, false, pFCursor);

IFeature pFeature = default(IFeature);
pFeature = pFCursor.NextFeature;
// Get First Feature
if (pFeature == null) {
    Interaction.MsgBox("No Features Selected!");
    // Just in case, but probably already taken care of earlier

long lFIndex = 0;
lFIndex = pFCursor.FindField(m_strGridIndexField);
// Replace with your field name
if (lFIndex > -1) {
    // Substute the correct data type to match the field type
    while ((pFeature != null)) {
        m_fValue = pFeature.Value(lFIndex);
        // Do something with the value stored in fValue
        pFeature = pFCursor.NextFeature;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.