Thank you so much. I am almost there. I have two descendants. One is checkbox
and the second is a text box. The current code populates the checkboxes. How
to populate the text boxes? Kindly look at the code below:
XPathNodeIterator nodesText =
nodesNavigator.SelectDescendants(XPathNodeType.Text, false); --> This only
selects the checkbox!!! (How to select the textbox here???)
while (nodesText.MoveNext())
{
//Console.Write(nodesText.Current.Name);
//Console.WriteLine(nodesText.Current.Value);
if (nodesText.Current.NodeType ==
XPathNodeType.Text)
{
nodesText.Current.SetValue("true"); --> This
sets the checkboxes value!!!!
}
}
I appreciate your help!! Thanks once again.
Daska
p.s. I love your articles! There are very few InfoPath experts out there!
You are one of them!
I'm not sure in what context the code you copied was being used, so not sure
why the Text nodes were retrieved, but try this instead:
XPathNodeIterator nodesText =
nodesNavigator.SelectDescendants(XPathNodeType.Element, false);
while (nodesText.MoveNext())
{
if (nodesText.Current.Name == "my:field1")
nodesText.Current.SetValue("true");
if (nodesText.Current.Name == "my:field2")
nodesText.Current.SetValue("MyValue");
}
or you could change the entire lot to this:
XPathNavigator DOM = this.MainDataSource.CreateNavigator();
XPathNodeIterator nodes = DOM.Select("/my:myFields/my:Options/my:Option",
NamespaceManager);
while (nodes.MoveNext())
{
nodes.Current.SelectSingleNode("my:field1",
NamespaceManager).SetValue("true");
nodes.Current.SelectSingleNode("my:field2",
NamespaceManager).SetValue("MyValue");
}
where my:field1 is your checkbox and my:field2 your text box.
I'm glad you enjoy the articles I publish. Thank you for your positive
feedback.
---
S.Y.M. Wong-A-Ton
> Thank you so much. I am almost there. I have two descendants. One is checkbox
> and the second is a text box. The current code populates the checkboxes. How
[quoted text clipped - 65 lines]
> > >
> > > Daska
daska - 23 Aug 2007 22:08 GMT
I can't thank you enough. You proved to be a Messiah. Thank you very very much.
Regards
Daska
> I'm not sure in what context the code you copied was being used, so not sure
> why the Text nodes were retrieved, but try this instead:
[quoted text clipped - 99 lines]
> > > >
> > > > Daska
S.Y.M. Wong-A-Ton - 24 Aug 2007 03:06 GMT
You're welcome!
---
S.Y.M. Wong-A-Ton
> I can't thank you enough. You proved to be a Messiah. Thank you very very much.
>
[quoted text clipped - 105 lines]
> > > > >
> > > > > Daska