C# – Get value from People Editor Control

cpeoplepickersharepoint

I have created a visual WebPart contains a people Editor control to pick the Manager Name(infact only one name).
The control is working fine but i would like to store the particular value to a variable using code during the button click . how can i achive this ? any help?

Best Answer

Hope this code is helpful for you..

public void btnSave_Click(object sender, System.EventArgs e)
{
   ….
   //where userPicker is Id of People picker control
   PickerEntity pe = (PickerEntity)userPicker.Entities[0];  
   string username = pe.Description;
   …
}