Hello,
of course you can use Matt´s suggestion for counting the number of rows in a repeating table. I have found another way of limit the number of rows. You can use the 'position' attribute of your repeating table as I will show you in the following example:
var repeatingTable = XDocument.DOM.SelectSingleNode(//my:repeatingTable[position() = 3]);
if (repeatingTable != null) // it s true when you try to add the 3th row
{
e.ReturnStatus = false;
e.ReturnMessage = "Max three rows...";
}
BTW: You can use this even if you want to force the user to insert at least one row minimum in a repeating table with the following check:
var repeatingTable = XDocument.DOM.SelectSingleNode(//my:repeatingTable[position() = 1]);
if (repeatingTable == null) // it s true when you try to add the 3th row
{
e.ReturnStatus = false;
e.ReturnMessage = "One row at least...";
}
All should be done in the OnBeforeChange event!
Hope that helps...