Problems with getting the row number (index) of the repeating table using e.Source.selectNodes("preceding-sibling::) - InfoPath Dev
in

InfoPath Dev

Problems with getting the row number (index) of the repeating table using e.Source.selectNodes("preceding-sibling::)

Last post 01-12-2009 03:30 PM by dyungn. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-11-2009 06:41 PM

    • dyungn
    • Not Ranked
    • Joined on 01-11-2009
    • Posts 2

    Problems with getting the row number (index) of the repeating table using e.Source.selectNodes("preceding-sibling::)

    Newbie here so go easy.  I am using Visual Studio 2003 and Infopath.  I access the a repeating table via OnAfterChange of one of the fields.  When I insert a new row, I get the correct row number using 

    int rowNumber =  e.Source.selectNodes("preceding-sibling::my:LeaveEntry/my:startDate").length + 1;

    but when I modify the field in the existing row, rowNumber is aloway 1.

     Can anybody help me here?  What is the difference entering OnAfterChange when inserting a new row as opposed to modifiying existing row.

     Dyung.

  • 01-11-2009 10:38 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Problems with getting the row number (index) of the repeating table using e.Source.selectNodes("preceding-sibling::)

    Hello Welcome to the Forums,

    onAfteChange, e.site is different from e.source node. If you want exact rowNumber count for new row and modifying the node means you have to use the below code,

    IXMLDOMNode parentNode = e.parentNode;

    int rowNumber =  parentNode.selectNodes("preceding-sibling::my:LeaveEntry/my:startDate").length + 1;

  • 01-12-2009 06:51 AM In reply to

    Re: Problems with getting the row number (index) of the repeating table using e.Source.selectNodes("preceding-sibling::)

    dyungn:
      Can anybody help me here?  What is the difference entering OnAfterChange when inserting a new row as opposed to modifiying existing row.

    The difference is the position of e.Source.  You can surround the row number calculation in a conditional statement like this:

    if(e.Source.nodeName.Equals("name of the repeating node"))  // e.g. e.Source.nodeName.Equals("my:group2")
    {
        int rowNumber =  e.Source.selectNodes("preceding-sibling::my:LeaveEntry/my:startDate").length + 1;
        // the rest of your code
    }

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-12-2009 03:30 PM In reply to

    • dyungn
    • Not Ranked
    • Joined on 01-11-2009
    • Posts 2

    Re: Problems with getting the row number (index) of the repeating table using e.Source.selectNodes("preceding-sibling::)

    Thanks Shiva, 

    I tried this with e.Site.parentNode (as e.parentNode was not an option) and it works fine.

    Thank you.

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.