Add new line in a repeating table - InfoPath Dev
in

InfoPath Dev

Add new line in a repeating table

Last post 07-26-2010 01:18 AM by alexia_net. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-23-2010 06:22 AM

    Add new line in a repeating table

    Hi. I am using the following code to add lines and info into a repeating table:

     

            public void QueueList(string[] tmp_strArrayQueueGr, string[] tmp_strArrayQueueFields, string[,]tmp_strArrayQueueValues, int tmp_intNrRec, int tmp_k)
            {
                XPathNavigator objRoot = this.MainDataSource.CreateNavigator();

                string myNameSpace = "";
                myNameSpace = NamespaceManager.LookupNamespace("my");

                   
                   XmlWriter writer = objRoot.SelectSingleNode(tmp_strArrayQueueGr[0], NamespaceManager).AppendChild();
                   writer.WriteStartElement(tmp_strArrayQueueGr[1], myNameSpace);
                    for (int i = 0; i < tmp_intNrRec; i++)
                    {                   
                        writer.WriteElementString(tmp_strArrayQueueFields[i], myNameSpace, tmp_strArrayQueueValues[tmp_k, i]);
                        writer.WriteEndElement();                   
                    }
                    writer.Close();
            }

     

    The problem is that when the program reaches the second value I get an error:

    "TOKEN EndElement IN STATE TopLevel WOULD RESULT IN AN INVALID XML DOCUMENT.

    Could anyone help me with this? Which instruction should I use to put all the info in the repeating table on the form? the repeating table has 3 columns and each time I add one line when I push a button. Thank you!

  • 07-23-2010 06:53 AM In reply to

    Re: Add new line in a repeating table

    writer.WriteEndElement() should be outside the for loop, not in it.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-26-2010 01:18 AM In reply to

    Re: Add new line in a repeating table

     Hi. Thank you for your answer. I have used

    writer.ToString ();

    instead of WriteEndElement  and it seems to be working just fine.

     

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.