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);
                        }
                    }

  • 相关阅读:
    npm 与 yarn 发展史
    关于oracle sql语句查询时表名和字段名要加双引号的问题
    Navicat工具mysql转库oracle步骤
    Linux根目录扩容方法及其涉及的相关磁盘操作
    Oracle中的数据类型详解
    一张图看懂钢铁生产工艺流程
    MYBATIS-PLUS关联查询,一对一、一对多
    直接替换Springboot jar包中的文件
    springboot配置数据库密码特殊字符报错问题
    教你一招,把 Win10 更新暂停到 N 年后的神奇方法
  • 原文地址:https://www.cnblogs.com/KingStar/p/1592736.html
Copyright © 2011-2022 走看看