zoukankan      html  css  js  c++  java
  • sharepoint 插入字段类型为People and group

      绑定类型为People and group

    private void BindOwner()
             {
                 using (SPSite site = new SPSite(siteurl))
                 {
                     using (SPWeb web = site.OpenWeb())
                     {
                         DataTable ownerTable = Make_Table();
                         foreach (SPUser user in web.SiteGroups["Owner"].Users)
                         {
                             if (user.Name != "System Account")
                             {
                                 DataRow row = ownerTable.NewRow();
                                 row["Name"] = user.Name;
                                 row["LoginName"] = user.LoginName;
                                 ownerTable.Rows.Add(row);
                             }
                         }
                         DropDownListOwner.DataSource = ownerTable;
                         DropDownListOwner.DataTextField = "Name";
                         DropDownListOwner.DataValueField = "LoginName";
                         DropDownListOwner.DataBind();
                     }
                 }
             }


             private DataTable Make_Table()
             {
                 DataTable nameTable = new DataTable("Names");
                 nameTable.Columns.Add("Name");
                 nameTable.Columns.Add("LoginName");
                
                 return nameTable;
             }

    插入时需注意的:

       using (SPSite site = new SPSite(siteurl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        try
                        {
                            site.AllowUnsafeUpdates = true;
                            web.AllowUnsafeUpdates = true;
                            SPList list = web.Lists["AuditSystem"];
                            item["Owner"] = web.SiteUsers[DropDownListOwner.SelectedValue];
                             item.Update();
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(ex.Message);
                        }
                    }

  • 相关阅读:
    MySQL的事务和视图
    MySQL中的常用函数
    高级查询(一)
    街道管理系统
    深入.NET平台和C#编程的错题
    appium python下的API方法
    Charles 使用教程
    appium,iOS下,ios_predicate等定位方式
    Linux -常用命令
    python-列表以及相关函数认识
  • 原文地址:https://www.cnblogs.com/KingStar/p/1592736.html
Copyright © 2011-2022 走看看