Copy data from Secondary Data Source to a Repeating Table in a Rep

K

Kalpana

Hi All

I have a SharePoint List and I want the data to be copied over to a
Repeating Table in a Repeating Section. I have a button on the Repeating
Section and When I click the button my Repeating Table gets populated.
However this works only for the first Repeating Section. If I have a second
Repeating section I couldn't get the button click to work. It only works on
the first section.

Here is the code - I don't know how to get a handle of the current position
of the Repeating Section or table


public void btnSelectWorkCodes_Clicked(object sender, ClickedEventArgs e)
{
// Write your code here.

//Access Secondary Data Source for the Work COde Group list
xnWorkCodeGroup = this.DataSources["Work Codes
Group"].CreateNavigator();
XPathNodeIterator WCGNodes =
xnWorkCodeGroup.Select("/dfs:myFields/dfs:dataFields/dfs:Work_Codes_Group",
NamespaceManager);
XPathNavigator rowsNav =
xnDoc.SelectSingleNode("/my:myFields/my:group4/my:NewEngagement/my:grpWorkCodes", this.NamespaceManager);

//Remove all the rows in the repeating table first
XPathNavigator lastchild =
rowsNav.SelectSingleNode("child::*[position() = last()]",
this.NamespaceManager);
XPathNavigator firstchild =
rowsNav.SelectSingleNode("child::*[position() = 1]", this.NamespaceManager);
if (firstchild != null || lastchild != null)
firstchild.DeleteRange(lastchild);

while (WCGNodes.MoveNext())
{
string myNameSpace = NamespaceManager.LookupNamespace("my");
using (XmlWriter writer =
MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group4/my:NewEngagement/my:grpWorkCodes", NamespaceManager).AppendChild())
{
writer.WriteStartElement("rptWorkCodes", myNameSpace);
writer.WriteElementString("chkWCSelect", myNameSpace,
"false");
writer.WriteElementString("txtWCTitle", myNameSpace,
WCGNodes.Current.SelectSingleNode("@Title", NamespaceManager).Value);
writer.WriteEndElement();
writer.Close();

}
}
}

Thanks for any help.....I tried the various combition of current() but get
the Xslt error

Thanks
Kalpana
 
A

Anand Chandawarkar

Hi Kalpana,

I had the same situation in one of my past projects. You can use something like this:

XPathNavigator secDSNav = DataSources["Final_Selection"].CreateNavigator();
XPathNodeIterator seciter = secDSNav.Select("/dfs:myFields/dfs:dataFields/dfs:Final_Selection", NamespaceManager);

I am making use of the XMLNodeIterator object to traverse through the nodes of the secondary datasource "Final_Selection" in my case. Then, to loop through all the SharePoint list items that you would have you can fill the repeating table using something like below:

while (seciter.MoveNext())
{

//Assignment of list item values into variables

}

You can get the current row of the iterator mentioned above using
string firstname = seciter.Current.SelectSingleNode("@FirstName", NamespaceManager).Value;

Hope that helps. Let me know if this resolves your issue.

Regards,
Anand
Hi All

I have a SharePoint List and I want the data to be copied over to a
Repeating Table in a Repeating Section. I have a button on the Repeating
Section and When I click the button my Repeating Table gets populated.
However this works only for the first Repeating Section. If I have a second
Repeating section I couldn't get the button click to work. It only works on
the first section.

Here is the code - I don't know how to get a handle of the current position
of the Repeating Section or table


public void btnSelectWorkCodes_Clicked(object sender, ClickedEventArgs e)
{
// Write your code here.

//Access Secondary Data Source for the Work COde Group list
xnWorkCodeGroup = this.DataSources["Work Codes
Group"].CreateNavigator();
XPathNodeIterator WCGNodes =
xnWorkCodeGroup.Select("/dfs:myFields/dfs:dataFields/dfs:Work_Codes_Group",
NamespaceManager);
XPathNavigator rowsNav =
xnDoc.SelectSingleNode("/my:myFields/my:group4/my:NewEngagement/my:grpWorkCodes", this.NamespaceManager);

//Remove all the rows in the repeating table first
XPathNavigator lastchild =
rowsNav.SelectSingleNode("child::*[position() = last()]",
this.NamespaceManager);
XPathNavigator firstchild =
rowsNav.SelectSingleNode("child::*[position() = 1]", this.NamespaceManager);
if (firstchild != null || lastchild != null)
firstchild.DeleteRange(lastchild);

while (WCGNodes.MoveNext())
{
string myNameSpace = NamespaceManager.LookupNamespace("my");
using (XmlWriter writer =
MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group4/my:NewEngagement/my:grpWorkCodes", NamespaceManager).AppendChild())
{
writer.WriteStartElement("rptWorkCodes", myNameSpace);
writer.WriteElementString("chkWCSelect", myNameSpace,
"false");
writer.WriteElementString("txtWCTitle", myNameSpace,
WCGNodes.Current.SelectSingleNode("@Title", NamespaceManager).Value);
writer.WriteEndElement();
writer.Close();

}
}
}

Thanks for any help.....I tried the various combition of current() but get
the Xslt error

Thanks
Kalpana

Submitted via EggHeadCafe - Software Developer Portal of Choice
ASP.NET Composite Controls
http://www.eggheadcafe.com/tutorial...2-65916778e72d/aspnet-composite-controls.aspx
 

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