I have a Street_Light shapefile. It contains a field (POLE_TYPE).
POLE_TYPE can only have two values: "concrete" or "iron"
I am trying to select POLE_TYPE=iron.
When I tried manually by selecting by attributes, it showed 454 features but when my code run it selects only one feature.
Where did I go wrong?
Here is my code:
ESRI.ArcGIS.ArcMapUI.IMxDocument mxd = ArcMap.Application.Document as ESRI.ArcGIS.ArcMapUI.IMxDocument;
ESRI.ArcGIS.Carto.IMap map = mxd.FocusMap;
for (int i = 0; i < map.LayerCount; i++)
{
ESRI.ArcGIS.Carto.ILayer lay = map.Layer[i];
if (map.Layer[i].Name == "Street_Light")
{
ESRI.ArcGIS.Carto.IFeatureLayer flay = lay as ESRI.ArcGIS.Carto.IFeatureLayer;
ESRI.ArcGIS.Carto.IFeatureSelection fsel = flay as ESRI.ArcGIS.Carto.IFeatureSelection;
ESRI.ArcGIS.Geodatabase.IQueryFilter qfltr = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
qfltr.WhereClause = "POLE_TYPE ='IRON'";
ESRI.ArcGIS.Geodatabase.IFeatureCursor cur = flay.Search(qfltr, true);
ESRI.ArcGIS.Geodatabase.IFeature fea = cur.NextFeature();
while (fea != null)
{
fsel.SelectFeatures(qfltr, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultAdd, true);
fea = cur.NextFeature();
}
mxd.ActiveView.Refresh();
}
}