Welcome to plsql4all.blogspot.com SQL, MYSQL, ORACLE, TERADATA, MONGODB, MARIADB, GREENPLUM, DB2, POSTGRESQL.

Monday 2 June 2014

Get Collection of Users List From People and Group Field In SharePoint List Programmatically

in aspx page:

   <SharePoint:PeopleEditor ID="peAssignedTo" Width="350px" runat="server" PlaceButtonsUnderEntityEditor="false"
                            AllowTypeIn="True" MultiSelect="true" EnableBrowse="True" AllowEmpty="false" />                        

in code behind:

  ArrayList _arrayList = new ArrayList();
                               //null checking
                                if (!string.IsNullOrEmpty(Convert.ToString(nitem["people and group fld name"])))
                                {
                                    SPFieldUserValueCollection users = nitem["people and group fld name"] as                                                  SPFieldUserValueCollection;
                                    if (users != null)
                                    {

                                        foreach (SPFieldUserValue user in users)
                                        {
                                            PickerEntity _pickerEntity = new PickerEntity();
                                            _pickerEntity.Key = user.User.LoginName;
                                            _pickerEntity.IsResolved = true;
                                            _arrayList.Add(_pickerEntity);
                                        }
                                        "idof people editor control".UpdateEntities(_arrayList);
                                    }

                                }

No comments:

Post a Comment

Please provide your feedback in the comments section above. Please don't forget to follow.