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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top