locked
How to check the given name in people picker control is user name or group in share point 2010 webaprt RRS feed

  • Question

  • I am developing a costume web part using vs 2010.. in the form i have a people picker control , user will enter the  group or user name in the people picker control. i have to find the given name is group or user name..and after i have to bind the details of the user or users in the group to a grid view.. i stuck at how to  check the give name in people picker control...

    Any suggestion please...

    Thanks in Advance..


    • Edited by TARUN00197 Monday, April 7, 2014 10:42 AM spelling corrections
    Monday, April 7, 2014 10:38 AM

Answers

  • You can check SPPrincipalType of every PickerEntity in the PeapleEditor control.
    Here is an example how to loop through every PickerEntity of a PiopleEditor control and check the type.

    foreach (PickerEntity pickerEntity in peopleEditor.ResolvedEntities)
    {
       SPPrincipalType principalType = (SPPrincipalType)Enum.Parse(typeof(SPPrincipalType), pickerEntity.EntityType);
       if (principalType == SPPrincipalType.User)
       {
            //your code for user           
       }
       else if (principalType == SPPrincipalType.SharePointGroup)
       {
            //your code for group
       }
    }
    
    

    • Marked as answer by TARUN00197 Tuesday, April 8, 2014 8:44 AM
    Monday, April 7, 2014 12:30 PM

All replies

  • You can check SPPrincipalType of every PickerEntity in the PeapleEditor control.
    Here is an example how to loop through every PickerEntity of a PiopleEditor control and check the type.

    foreach (PickerEntity pickerEntity in peopleEditor.ResolvedEntities)
    {
       SPPrincipalType principalType = (SPPrincipalType)Enum.Parse(typeof(SPPrincipalType), pickerEntity.EntityType);
       if (principalType == SPPrincipalType.User)
       {
            //your code for user           
       }
       else if (principalType == SPPrincipalType.SharePointGroup)
       {
            //your code for group
       }
    }
    
    

    • Marked as answer by TARUN00197 Tuesday, April 8, 2014 8:44 AM
    Monday, April 7, 2014 12:30 PM
  • Thank you maruthi...
    Tuesday, April 8, 2014 8:45 AM