programmatically adding rows to Infopath repeating table - rows have buttons - InfoPath Dev
in

InfoPath Dev

programmatically adding rows to Infopath repeating table - rows have buttons

Last post 02-09-2010 05:54 PM by Jimmy. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-09-2010 09:37 AM

    • ChuckD
    • Not Ranked
    • Joined on 02-09-2010
    • Posts 1

    programmatically adding rows to Infopath repeating table - rows have buttons

    Hi,

    I have been using the following to add rows to a repeating table:

    XmlDocument doc = new XmlDocument();
    XmlNode group = doc.CreateElement("group2", NamespaceManager.LookupNamespace("my"));
    
    XmlNode field = doc.CreateElement("field1", NamespaceManager.LookupNamespace("my"));
    XmlNode node = group.AppendChild(field);
    node.InnerText = "Cell 1";
    
    field = doc.CreateElement("field2", NamespaceManager.LookupNamespace("my"));
    node = group.AppendChild(field);
    node.InnerText = "Cell 2";
    
    field = doc.CreateElement("field3", NamespaceManager.LookupNamespace("my"));
    node = group.AppendChild(field);
    node.InnerText = "Cell 3";
    
    doc.AppendChild(group);
    
    MainDataSource.CreateNavigator().SelectSingleNode(
    "/my:myFields/my:group1",
    NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());
     
    However Cell 3 is no longer a text field, but is a button.  Thus, I need to add a row, fill in the values for the first
    two columns, and somehow get a button to appear. I tried cloning an existing
    row, which works nicely, but I can't seem to get ahold of the row and put values in the fields.
    Any help would be much appreciated. 
    Thanks in Advance.
  • 02-09-2010 05:54 PM In reply to

    Re: programmatically adding rows to Infopath repeating table - rows have buttons

     What happens if you remove this part?:

    field = doc.CreateElement("field3", NamespaceManager.LookupNamespace("my"));
    node = group.AppendChild(field);
    node.InnerText = "Cell 3";

    The button is part of the repeating table control. It's not something you manually add to each row from the code.
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.