Programmatically Update Secondary Data Connection Sharepoint List

A

aspnerd

Is there a way to programmatically update a secondary data connection
record?

I can query the secondary list and retrieve the data, but I'm unable
to set the value.

I haven't been able to locate anything online which helps...

Here is what I tried...(below) and it said I couldn't update it
because it was a method group or something like that...

Can it be done?


DataSource xdsSequenceNumber = this.DataSources["Sequence Numbers"];

XPathNavigator xnSequenceNumber =
xdsSequenceNumber.CreateNavigator().SelectSingleNode("/dfs:myFields/
dfs:dataFields/dfs:Sequence_Numbers/@SequenceNumber[../@FormName =
'xxxxx']", NamespaceManager);

xnSequenceNumber.SetValue(Convert.ToString((Convert.ToInt32(xnSequenceNumber.Value)
+ 1)));
 
S

S.Y.M. Wong-A-Ton

Yes, you can. You are on the right track. I think you need to double-check
your XPath expression to see whether it is returning 1 node to update or a
group of nodes.
 
S

S.Y.M. Wong-A-Ton

One more thing: Secondary data sources to SharePoint lists contain
attributes, so you might have to retrieve a node and then use its Attributes
collection to update the value of an attribute instead of using SetValue on
the node itself. There might also be a SetAttribute method that you can use.
Have a play with it; if you still cannot solve it, let me know and I'll look
deeper into the issue for you.
 
A

aspnerd

Yes, you can. You are on the right track. I think you need to double-check
your XPath expression to see whether it is returning 1 node to update or a
group of nodes.
---
S.Y.M. Wong-A-Ton



aspnerd said:
Is there a way to programmatically update a secondary data connection
record?
I can query the secondary list and retrieve the data, but I'm unable
to set the value.
I haven't been able to locate anything online which helps...
Here is what I tried...(below) and it said I couldn't update it
because it was a method group or something like that...
Can it be done?
DataSource xdsSequenceNumber = this.DataSources["Sequence Numbers"];
XPathNavigator xnSequenceNumber =
xdsSequenceNumber.CreateNavigator().SelectSingleNode("/dfs:myFields/
dfs:dataFields/dfs:Sequence_Numbers/@SequenceNumber[../@FormName =
'xxxxx']", NamespaceManager);
xnSequenceNumber.SetValue(Convert.ToString((Convert.ToInt32(xnSequenceNumbe­r.Value)
+ 1)));- Hide quoted text -

- Show quoted text -

It should only be returning 1 node, since I'm filtering and there is
only one record for that....


I'm also doing the same thing for a field in the
maindatasource. ...the form itself...I am using this...


private int CurrentStep
{
get
{
XPathNavigator _CurrentStep =
MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/
my:CurrentStep", NamespaceManager);
return Convert.ToInt32(_CurrentStep.Value);
}
set
{
XPathNavigator _CurrentStep =
MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/
my:CurrentStep", NamespaceManager);
_CurrentStep.SetValue(value.ToString());
}
}

And that works perfectly...
 
A

aspnerd

One more thing: Secondary data sources to SharePoint lists contain
attributes, so you might have to retrieve a node and then use its Attributes
collection to update the value of an attribute instead of using SetValue on
the node itself. There might also be a SetAttribute method that you can use.
Have a play with it; if you still cannot solve it, let me know and I'll look
deeper into the issue for you.
---
S.Y.M. Wong-A-Ton



aspnerd said:
Is there a way to programmatically update a secondary data connection
record?
I can query the secondary list and retrieve the data, but I'm unable
to set the value.
I haven't been able to locate anything online which helps...
Here is what I tried...(below) and it said I couldn't update it
because it was a method group or something like that...
Can it be done?
DataSource xdsSequenceNumber = this.DataSources["Sequence Numbers"];
XPathNavigator xnSequenceNumber =
xdsSequenceNumber.CreateNavigator().SelectSingleNode("/dfs:myFields/
dfs:dataFields/dfs:Sequence_Numbers/@SequenceNumber[../@FormName =
'xxxxx']", NamespaceManager);
xnSequenceNumber.SetValue(Convert.ToString((Convert.ToInt32(xnSequenceNumbe­r.Value)
+ 1)));- Hide quoted text -

- Show quoted text -

ok CORRECTION ....the code 'works'...sort of... it changes the value
in the page...but in the secondary list (it's a retrieve data
connection) it doesn't actually save the change to the data list. It
only changes it in that page for the time being....


so how can I save it to the data list in sharepoint so that it sticks?
 
S

S.Y.M. Wong-A-Ton

Yes, you can change the data in the sec DS, but that will not do anything in
your SharePoint list. An MSDN article has just been published on submitting
data to a SharePoint list; see
http://msdn2.microsoft.com/en-us/library/cc162745.aspx
---
S.Y.M. Wong-A-Ton


aspnerd said:
One more thing: Secondary data sources to SharePoint lists contain
attributes, so you might have to retrieve a node and then use its Attributes
collection to update the value of an attribute instead of using SetValue on
the node itself. There might also be a SetAttribute method that you can use.
Have a play with it; if you still cannot solve it, let me know and I'll look
deeper into the issue for you.
---
S.Y.M. Wong-A-Ton



aspnerd said:
Is there a way to programmatically update a secondary data connection
record?
I can query the secondary list and retrieve the data, but I'm unable
to set the value.
I haven't been able to locate anything online which helps...
Here is what I tried...(below) and it said I couldn't update it
because it was a method group or something like that...
Can it be done?
DataSource xdsSequenceNumber = this.DataSources["Sequence Numbers"];
XPathNavigator xnSequenceNumber =
xdsSequenceNumber.CreateNavigator().SelectSingleNode("/dfs:myFields/
dfs:dataFields/dfs:Sequence_Numbers/@SequenceNumber[../@FormName =
'xxxxx']", NamespaceManager);
xnSequenceNumber.SetValue(Convert.ToString((Convert.ToInt32(xnSequenceNumbe­r.Value)
+ 1)));- Hide quoted text -

- Show quoted text -

ok CORRECTION ....the code 'works'...sort of... it changes the value
in the page...but in the secondary list (it's a retrieve data
connection) it doesn't actually save the change to the data list. It
only changes it in that page for the time being....


so how can I save it to the data list in sharepoint so that it sticks?
 

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