1

I have one requirement in which I have to display the saved users to the share point people editor control. For this I am saving the user names to People/Group column. And i am using the following code for taking theis user to people editor control.

SetPeopleEditor(item, Constants.FieldNames.IT_DIRECTOR, pe_ITDirector, oWeb);

The definition of the aboe method is shown below.

private PickerEntity SetPeopleEditor(SPListItem item, string columnName, PeopleEditor peopleEditor, SPWeb web)
{
    ArrayList entityArrayList = new ArrayList();
    PickerEntity entity = null;
    if (item[columnName] != null)
    {
        char[] to_splitter = { ';' };
        string to_list = item[columnName].ToString(); // Reads value stored in SPList. (i.e., "Domain\User1; Domain\User2")
        string[] arr = to_list.Split(to_splitter);
        string user = string.Empty;
        for (int i = 1; i < arr.Length; i++)
        {
            if ((i % 2) != 0)
            {
                user = arr[i].Substring(arr[i].IndexOf("#") + 1);
                entity = new PickerEntity();
                entity.Key = user;
                entity.IsResolved = true;
                entity = peopleEditor.ValidateEntity(entity);
                entityArrayList.Add(entity);
            }
        }


    }
    return entity;
}

But unfortunately the control always showing empty value. How can I achieve this by populating data to the people editor control

1
  • Hi I am facing the same issue. Where you able to resolve the issue and if yes how
    – SiD
    Commented Apr 17, 2018 at 10:09

1 Answer 1

0

Please check out this link:
It should answer your question:
http://www.mindfiresolutions.com/How-to-get-and-set-the-value-of-a-people-editor-control-programatically-in-SharePoint--960.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.