How to programatically add repeated rows ?

S

stephanperrin

I would like to generate automatically a table with a number rows
depending on a variable ?
Thx !
 
A

Andy Bonner

Hi Stephan

You'd want to get hold of the repeating group node, clone it, change the
values, then add it after the original node.

Something along these lines

XPathNavigator repeatingNode =
MainDataSource.CreateNavigator().SelectSingleNode("/my:Example/my:RepeatingNode",
NamespaceManager);
for(int i=1;i<=10;i++)

{

XPathNavigator newNode = repeatingNode.Clone();

newNode.SelectSingleNode("/my:Example/my:RepeatingNode/my:ID",
this.NamespaceManager).SetValue(i.ToString());

newNode.SelectSingleNode/my:Example/my:RepeatingNode/my:Name",
this.NamespaceManager).SetValue("Example " + i.ToString());

try

{

repeatingNode.InsertAfter(newNode);

}

catch (Exception)

{

}

}

repeatingNode.DeleteSelf();

Hope this helps
Andy
 
Top