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

Monday 2 June 2014

Add Users or User Group to fld in sharepoint list programmatically

in aspx page:

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

in code behind:

 SPFieldUserValueCollection id1UserCollection = new SPFieldUserValueCollection();
                string[] id1UsersSeperated = id1.CommaSeparatedAccounts.Split(',');
                foreach (string UserSeperated in peStaffInvolvedUsersSeperated)
                {
                    SPUser User = oWeb.EnsureUser(UserSeperated);
                    SPFieldUserValue UserName = new SPFieldUserValue(oWeb, User.ID, User.LoginName);
                    id1UserCollection.Add(UserName);
                    CheckUserifExist(User);
                }
                itemToAdd["people and group"]=idUserCollection;

No comments:

Post a Comment

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