Pages

Friday, January 13, 2012

How to get the SPUser Object from SPfield(Person or Group)

Hello Friends

Here is the code how to get the SPUser Object from SPfield(Person or Group) from a sharepoint list and get the email address, login name of that user.

Here is a snippest of code.

SPFieldUser userField = (SPFieldUser)SPContext.Current.Web.Lists["SiteName"].Fields.GetField("AdminName");
                SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(myitem["AdminName"].ToString());
SPUser user = fieldValue.User;
//user.LoginName;

Happy Coding
Disha Shah!!!

No comments:

Post a Comment