Copying Repeating Table to Another One

D

Deniz Yalman

I want to copy a repeating table to another one. I have a repeating table
which is writable for inserting data as source and the other repeating table
is read-only as destination. When the user inserts data to the source table
and click the button, i want to copy data of the source to the destination
table.

source table:
- products (repeating group)
- type
- name

destination table:
- copyProducts (repeating group)
- copyType (readonly)
- copyName (readonly)

This is my code in the click event:

XPathNodeIterator source =
MainDataSource.CreateNavigator().Select("/my:myFields/my:products",
NamespaceManager);
XPathNavigator destination =
MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:copyProducts", NamespaceManager);
XPathNavigator temp = this.CreateNavigator();

string s = String.Empty;
while (source.MoveNext())
{
//for create new row in destination table
destination.InsertAfter(destination.Clone());

//first method to try to fill copyType column
temp = source.Current.Clone();
temp.MoveToFirstChild();
s = temp.Value;

destination.SelectSingleNode("/my:myFields/my:copyProducts/my:copyType",
NamespaceManager).SetValue(s);

//second method to try to fill copyName column

destination.SelectSingleNode("/my:myFields/my:copyProducts/my:copyName",
NamespaceManager).SetValue(source.Current.SelectSingleNode("/my:myFields/my:products/my:Name", NamespaceManager).Value);
}

As you see, i tried two different methods on the columns but both of them
returns false data.

In the first method, "source.Current.InnerXml" includes "\r\t\t\t\t<xml bla
bla>\r\t\t\t<blabla>\t\t\t" because of whitespaces. Data is true but
whitespaces make "\r\t\t" etc. So s' value is "\r\t\t\t". They are all return
and tab characters..

In the second method, in spite of "source.Current" including true data,
destination table's all rows are filled with the first row of the source's.
Probably i can't use "Current" property properly.

Is there anyone to help me to copy repeating table?

Thanks in advance.
 

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