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!

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, privacy policy and cookie policy

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