locked
Infopath data move into list programatically? RRS feed

  • Question

  • Hi All,

    I have a info path form. I want to move all info path data into list.

    In info path form have a two repeating table.

    Outer repeating table is used for populate Dropdown list item and inner repeating table is used for add multiple vendor for that particular list item.

    Its working for save data into list.

    But I want to add multiple vendor under that particular Dropdown list item.

    I want to save info path to the list like this.

                                                        1) Laptop Dropdown list item

                                                                  Kamlesh

                                                                  Vikram

                                                           2) Desktop Dropdown list item

                                                                  Amol

                                                                  Machindra

    I am able to show all data under list item.

    Following is my code snippet.

     using (SPWeb myWeb = mySite.OpenWeb())
                    {
    
                        XPathNodeIterator orderItems;
                        XPathNodeIterator orderItems1;
    
                        if (myWeb != null && myWeb.Lists["ResponceTrack"] != null)
                        {
    
                            SPList shippingList = myWeb.Lists["ResponceTrack"];
    
                            myWeb.AllowUnsafeUpdates = true;
    
                            orderItems = this.MainDataSource.CreateNavigator().Select("/my:myFields/my:group1/my:group2", NamespaceManager);
                            if (orderItems != null)
                            {
                                while (orderItems.MoveNext())
                                {
                                    // Add rows from the form where user selected an item and specified a quantity.
    
    
                                    string strItem = orderItems.Current.SelectSingleNode("./my:Item", NamespaceManager).Value;
    
                                    if (strItem != string.Empty)
                                    {
                                        SPListItem shipItem = shippingList.AddItem();
                                        shipItem["Title"] = strItem;
    
                                        shipItem.Update();
                                    }
    
                                    orderItems1 = this.MainDataSource.CreateNavigator().Select("/my:myFields/my:group1/my:group2/my:group3/my:group4", NamespaceManager);
                                    if (orderItems1 != null)
                                    {
                                        while (orderItems1.MoveNext())
                                        {
                                            // Add rows from the form where user selected an item and specified a quantity.
    
    
                                            string strItem1 = orderItems1.Current.SelectSingleNode("./my:field10", NamespaceManager).Value;
                                            
                                            if (strItem1 != string.Empty)
                                            {
                                                SPListItem shipItem = shippingList.AddItem();
                                                shipItem["Item"] = strItem1;
    
                                                shipItem.Update();
                                            }
                                        }
                                    }
                                }
                            }
    
                            myWeb.AllowUnsafeUpdates = false;
                            // e.CancelableArgs.Cancel = false;
                            //return;
                        }
                    }
                }
            }
        }

    Thanks

    BKMore



    • Edited by BKMore Wednesday, May 2, 2012 1:06 PM
    Wednesday, May 2, 2012 1:02 PM