0

I am trying to fetch name alone from people picker in a sharepoint custom list and display it in a gridview- usercontrol. currently Iam getting whole details which include ID and name(eg: 19;# lastname, firstname(company)). But I need name alone. How can I do that. Kindly help me.

Thanks in advance!

4
  • Are you using SharePoint designer? Commented Aug 24, 2016 at 13:26
  • yes, Iam using sharepoint designer.
    – jacob
    Commented Aug 24, 2016 at 13:39
  • Please refer this Answer. sharepoint.stackexchange.com/questions/93478/… Commented Aug 24, 2016 at 14:03
  • sorry I'm new to this programming. Am I able to get name alone by using lookup.
    – jacob
    Commented Aug 25, 2016 at 11:02

1 Answer 1

0

I think there is no method to get name alone from a list and display in grid view.

So finally I did by concatenating.

foreach (SPListItem itm in itmcoll)    
{    
     DataRow dr = dt.NewRow();    
     string ProjMangrLogged = Convert.ToString(itm["Project ManagerID"]);
     int start = ProjMangrLogged.IndexOf("#") + 1;  
     int end=ProjMangrLogged.IndexOf("(",start);

     string ProjMangr = ProjMangrLogged.Substring(start, end - start);

     dr["Item Project ManagerID"] = ProjMangr;

     dt.Rows.Add(dr);   
}

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.