Get single user from PeopleEditor and update column of type “People
and Groups”.

Aspx Page:
<%@ Register TagPrefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>

<wssawc:peopleeditor id="UserPickerRequestedFor" runat="server" allowempty="False"
height="20px" multiselect="true" selectionset="User" showcreatebuttoninactivedirectoryaccountcreationmode="True"
validatorenabled="True" width="300px"></wssawc:peopleeditor>

Aspx.Cs Page:
PickerEntity UserEntity = new PickerEntity();
int usrCount = UserPicker.Accounts.Count;
for (int i = 0; i < usrCount; i++)
  {
   UserEntity = (PickerEntity)UserPicker.Entities[i];
   string  userAcctName = UserEntity.Description;
   Hashtable peopleEditorData = UserEntity.EntityData;
   string strUserLogin = UserEntity.Key;
   SPSecurity.RunWithElevatedPrivileges(delegate()
   {
   using (SPSite elevatedSite = new SPSite(web.Site.ID))
   {
    elevatedSite.AllowUnsafeUpdates = true;
    SPWeb elevatedWeb = elevatedSite.OpenWeb(web.ID);
    {
       elevatedWeb.AllowUnsafeUpdates = true;
       SPUser user = elevatedWeb.EnsureUser(strUserLogin);
    }
   }
 });
SPUser usrToADD = web.AllUsers[strUserLogin];
reqItem["ReqMgr"] = usrToADD;

 


No comments: