InfoPath 的 Repeat Table 重复表中的数据,如何用C# 读取?

来源:互联网 发布:淘宝阿里旅行人工电话 编辑:程序博客网 时间:2024/04/25 23:50

引自:

 

Q-

我在InfoPath2007里有一个重复表group2,分三列field1,field2,field3.请问我如何用c#获取到重复表中每行field1,field2,field3的值?

 

 

A-

XPathNodeIterator nodes = MainDataSource.CreateNavigator().Select("/my:myFields/my:group2", NamespaceManager);

            foreach (XPathNavigator node in nodes)
            {
                XPathNavigator n = node.SelectSingleNode("my:field1", NamespaceManager);
            }
        }

 

 

下面的代码可以用在 Web Service 中以处理 Repeat Table的数据,因其数据是 xmlNode 格式,故需要进行特殊处理。

(其中 p_Details 为Repeat Table 对应的 xmlNode )

 

               XmlNodeList _NL;

 

                for (int i = 0; i < p_Details.ChildNodes.Count; i++)
                {
                    _NL = p_Details.ChildNodes[i].ChildNodes;

                    _iItem_No = i + 1;
                    _sMain_Category = _NL[0].InnerText;
                    _sDescription = _NL[1].InnerText;
                    _iQuantity = int.Parse(_NL[2].InnerText);
                    _nUnit_Price = decimal.Parse(_NL[3].InnerText);
                    _nTotal_Cost = decimal.Parse(_NL[4].InnerText);
                    _sBudget_Code = _NL[5].InnerText;
                    _nBudget_Cost = decimal.Parse(_NL[6].InnerText);
                    _sReason = _NL[7].InnerText;
                    _sLocation = _NL[8].InnerText;
                    if (_sMain_Category.Trim() != "")
                    {
                        iResult = Update_Dtl(p_sForm_No, _iItem_No, _sMain_Category, _sSub_Category, _sDescription,
                                                _iQuantity, _nUnit_Price, _nTotal_Cost, _sBudget_Code, _nBudget_Cost,
                                                _sReason, _sLocation);
                    }
                }