Hi Hilary,
I was revisiting this issue because I ran into a problem when running the code. To update, here is the code I adapted to C# from your post earlier:
public void CTRL_createSites_Clicked(object sender, ClickedEventArgs
e)
{
//Get the value of the text box that holds the number of rows to
add
string xpath = "/my:OMS/my:UniversalInformation_sec/my:UI_Addrows_sec/my:UI_AddRows_txt";
XPathNavigator field =
MainDataSource.CreateNavigator().SelectSingleNode(xpath,
NamespaceManager);
//Get the node that will be repeated/cloned
xpath = "/my:OMS/my:SiteSpecificInfo_sec";
XPathNavigator group =
MainDataSource.CreateNavigator().SelectSingleNode(xpath,
NamespaceManager);
//Cast the field's value to an integer to know how many rows to
add
int rows = field.ValueAsInt;
//Loop, Cloning Group
int i;
for (i = 1; i <= rows - 1; i++)
{
XPathNavigator newRow = group.Clone();
newRow.InsertAfter(group);
}
}
What's happening are the following issues:
1. If I try to create more than 20 rows, the program usually (90% of the time) locks up and won't respond.
2. If I select a node with information already in it, then it clones it and creates 'x' number of cloned rows with the same info. (This isn't a problem, just noting that this is what happens. I'm pretty sure that's what the code is telling it to do anyway, but for the original issue in this post, the caveat was to start with a blank row, right?)
The real issue is the time it takes to create the rows with the code (example: it takes about 9 seconds to clone 5 rows, and another 18 seconds if I clone 5 more right after that). I don't know why it locks up, but it may have something to do with the number of fields located in that group string = xpath. When cloning the rows, does it clone the controls that are only inserted in the form, or the whole schema associated with that group?
Is there a faster way? Perhaps without cloning the node? I am wondering about the AppendChild() method... I'm not sure if that suggestion even makes sense....