I'm new to InfoPath and not realy sure if I like it. So far I found some severe limitations as to flexebility of design.
Here is my question: I'm trying to create a form that would allow a user to create multiples of two types of tables. Both tables will have query button to call web service and based on the user input fill the row with appropriate data. I got that part done. I have a button that searches for "field1" text, calls web service and populated the other fields in the new row with data then inserts it to the table. The second part is giving me even more head ache. I need the user to be able to add such tables on demand with unique textbox header and their own data. I use repeating section for this purpose and all I get is duplicate of the same table and inseparable from each other...
How do I get this done...?
here is the code I have so far for the first part:
public void CTRL114_5_Clicked(object sender, ClickedEventArgs e)
{
// Write your code here.XPathNavigator rTable = MainDataSource.CreateNavigator();XPathNodeIterator tableRows = rTable.Select("/my:myFields/my:group1/my:group2", NamespaceManager);
// Write your code here.Webservice.Service service = new TableAddRowButtonTest.Webservice.Service();
service.UseDefaultCredentials =
true;XmlNode doc = service.getVendorDocumentInfoByID(e.Source.SelectSingleNode("/my:myFields/my:group1/my:group2[" + tableRows.Count + "]/my:field1", this.NamespaceManager).ToString());
string test = doc.FirstChild.Attributes.Item(0).Value.ToString();string test2 = doc.FirstChild.Attributes.Item(1).Value.ToString();if (!test.Equals("") & !test2.Equals(""))
{
XPathNavigator reTable = MainDataSource.CreateNavigator();XPathNavigator reTableRows = reTable.SelectSingleNode("/my:myFields/my:group1/my:group2[" + tableRows.Count + "]", NamespaceManager);
string myNamespace = NamespaceManager.LookupNamespace("my");using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1", NamespaceManager).AppendChild())
{
writer.WriteStartElement(
"group2", myNamespace);writer.WriteElementString("field1", myNamespace, e.Source.SelectSingleNode("/my:myFields/my:group1/my:group2[" + tableRows.Count + "]/my:field1", this.NamespaceManager).ToString());
writer.WriteElementString(
"field2", myNamespace, test);writer.WriteElementString("field3", myNamespace, test2);
writer.WriteEndElement();
writer.Close();
}
reTableRows.DeleteSelf();
}
}