zoukankan      html  css  js  c++  java
  • 如何通过Infopath2010编程方程向Sharepoint List提交数据继(完)

    如何通过Infopath2010编程方程向Sharepoint List提交数据  针对上一篇修改了一下,可以直接提交重复表里的数据到列表中,代码实现如下:

    public void CTRL1_5_Clicked(object sender, ClickedEventArgs e)
            {
                // 在此处编写代码。
                //using (SPSite site = SPContext.Current.Site)
                using (SPSite site = new SPSite("http://bany-pc"))
                {
                    if (site != null)
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                            // Turn on AllowUnsafeUpdates on the site
                            web.AllowUnsafeUpdates = true;

                            // Update the SharePoint list based on the values
                            // from the InfoPath form
                            SPList list = web.GetList("/Lists/List3/AllItems.aspx");
                            XPathNavigator root = this.CreateNavigator();                       

                            XPathNodeIterator NodeIter = this.MainDataSource.CreateNavigator().Select("/my:myFields/my:Group/my:Details", this.NamespaceManager);


                            if (list != null)
                            {                           
                                foreach (XPathNavigator myf in NodeIter)
                                {
                                    SPListItem item = list.Items.Add();                         

                                    item["部门"] = myf.SelectSingleNode("my:部门", NamespaceManager).Value;
                                    item["单位"] = myf.SelectSingleNode("my:单位", NamespaceManager).Value;
                                    item["姓名"] = myf.SelectSingleNode("my:姓名", NamespaceManager).Value;
                                
                                    item.Update();
                                }
                            }

                            // Turn off AllowUnsafeUpdates on the site
                            web.AllowUnsafeUpdates = false;

                            // Close the connection to the site
                            web.Close();
                        }

                        // Close the connection to the site collection
                        site.Close();
                    }
                }

    image

    image

    image

  • 相关阅读:
    编写BinIoDemo.java的Java应用程序,程序完成的功能是:完成1.doc文件的复制,复制以后的文件的名称为自己的学号姓名.doc。
    编写IoDemo.java的Java应用程序,程序完成的功能是:首先读取text.txt文件内容,再通过键盘输入文件的名称为iodemo.txt,把text.txt的内容存入iodemo.txt
    编写TextRw.java的Java应用程序,程序完成的功能是:首先向TextRw.txt中写入自己的学号和姓名,读取TextRw.txt中信息并将其显示在屏幕上。
    事物 视图 与索引
    大家跟我一起涨知识(高级查询与分页)
    涨知识Style
    数据库打印图形
    SQL 编程
    新闻发布系统
    数据库分页储存
  • 原文地址:https://www.cnblogs.com/Bany/p/2982771.html
Copyright © 2011-2022 走看看