绑定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;
         }

你可能感兴趣的:(group)