Add a row to a reapeating table with a button

V

virgul

Hi,

I try to add a button in C# who can add a row to a reapeating table
when I click this button?

Anybody has an idea about how to do that? The class or somethings
else(a website for example)?

If it's possible is it in the same time possible to add a various
content based on a external XML content!


Thanks for your help it's very appreciate!!

Thierry
 
M

Michelle B

Example schema where repeatingtable is a repeating group in the main
datasource.

<my:myFields>
<my:repeatingtable>
<my:field1 />
<my:field2 />
<my:field3 />
</my:repeatingtable>
</my:myFields>

Sample Code:

IXMLDOMNode row = thisXDocument.DOM.selectSingleNode("//my:repeatingtable");
row = row.cloneNode(true);
row.selectSingleNode("my:field1").text = "new row field 1";
row.selectSingleNode("my:field2").text = "new row field 2";
row.selectSingleNode("my:field3").text = "new row field 3";

IXMLDOMNode parent = thisXDocument.DOM.selectSingleNode("/my:myFields");
parent.appendChild(row);
 
K

KjellSJ

If your XSD is more complex than the sample schema, e.g. an <xs:sequence>
with more elements after the <repeatingtable> element, then appendChild will
give an XSD validation error. Use insertBefore to ensure that the code will
always be able to add the new row:

parent.insertBefore(rowClone, rowOne);

Note that InfoPath script depends on MSXML which do not have an insertAfter
method. Use managed code if you need the more complete XML support of the
System.Xml namespace.

KjellSJ
http://kjellsj.blogspot.com
 
Top