Sharepoint 用户或用户组(允许多重选择)获取
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | if (item["Users"] != null) { SPFieldUser WIuField = (SPFieldUser) item.ParentList.Fields.GetFieldByInternalName("Users"); if (!WIuField.AllowMultipleValues) //允许多重选择 { SPFieldUserValue userValue = new SPFieldUserValue(web, item["Users"].ToString()); //userValue.User.Name ; } else { SPFieldUserValueCollection userValues = item["Users"] as SPFieldUserValueCollection; foreach(SPFieldUserValue userValue in userValues) { if (userValue.User != null) { //userValue.User.Name } else { SPGroup userGroup = web.SiteGroups.GetByID(userValue.LookupId); //userGroup.Users; } } } } |