When an OnAfterChange event fires for a control in a repeating table/section, the eventObj for that event is already relative to the current row. So for example, if you have a data structure like this
Table
Row
DatabaseId
TextBox
CheckBox
Button
If you select the check box, you can simple use a relative XPath to get the DatabaseID such as:
eventObj.Site.selectSingleNode("../DatabaseID").text;
The button itself, when clicked simply points to the Row itself. Thus you can reference any of the children of that Row as such:
eventObj.Source.selectSingleNode("DatabaseID").text
- - - - -
If you are looking to find the row number when clicking on a button, you can use a count of previous "Row"s like this:
var nCount = eventObj.Source.selectNodes("preceding-sibling::Row").length + 1;
Greg Collins [InfoPath MVP]
InfoPath Dev