IFeature.set_Value not being saved

Discussion created by murswan on Jan 5, 2012
Latest reply on Jan 12, 2012 by murswan
Hi all, I am trying to troubleshoot a portion of our program that fires during the onExplode event using arcObjects and A user can select, through our custom toolbar, the button "Explode Multi Part Features". We have a bit of code that runs for some other things but the reason for my question is that we have a field called Poly_no that I need to update. (If there are two parts to explode then I want one of the newly created polygon's to be numbered "x" and then each one after to increment accordingly). My code is this:

public void OnExplodeFeatures()
           int intPOLY_NO = 0;
           string sPolyNo = string.Empty;
            //Get currently selected files
            IEnumFeature selectedFeatures = RMF93.BLL.EditorHelper.Editor.EditSelection as IEnumFeature;
            IFeature pFeat = selectedFeatures.Next();

            if (RMF93.BLL.EditorHelper.intPolyNo == 0) //store poly_no
                sPolyNo = pFeat.get_Value(pFeat.Fields.FindField(Constants.CONST_FLD_POLY_NO)).ToString();
                intPOLY_NO = Convert.ToInt32(sPolyNo);              
                RMF93.BLL.EditorHelper.intPolyNo = intPOLY_NO;
                intPOLY_NO = RMF93.BLL.EditorHelper.intPolyNo;

            string sGUID = pFeat.get_Value(pFeat.Fields.FindField(Constants.CONST_FLD_PK_POLY_GUID)).ToString();
            if (sGUID.Length > 0)
                while (pFeat != null)
                    sGUID = "{" + System.Guid.NewGuid().ToString() + "}";

--> This line works all the time
                    pFeat.set_Value(pFeat.Fields.FindField(Constants.CONST_FLD_PK_POLY_GUID), sGUID);

--> This is the line that won't save                   other than the first time through
pFeat.set_Value(pFeat.Fields.FindField(Constants.CONST_FLD_POLY_NO), intPOLY_NO);

                    pFeat = selectedFeatures.Next();
                    RMF93.BLL.EditorHelper.intPolyNo = intPOLY_NO + 1; //Increment Poly_No & store
            catch (Exception ex)


I can't figure this out as the other command we have is OnSplit and it works just fine. The field (Poly_No) is editable and in fact I have tried several different fields just to make sure but none will stick. Now the reason why I know I'm doing something wrong is that the first time through the while statement any values I set do stick (GUID always sticks regardless), just the subsequent ones do not (so for the first polygon feature, changes are saved and then when it moves to the next feature part thats when the changes are ignored for the Poly_No only the GUID is fine. My explanation is probaly even more confusing, sorry :o

Any help or insight would be appreciated tons!!