Getting User data from SPfield

Posted on August 4, 2009. Filed under: Code Snippets | Tags: , , |

private SPUser getUser(SPListItem item, SPField listUser)

{

string listUserValue = item[listUser.Title].ToString();

SPFieldUser field = (SPFieldUser)listUser;

SPFieldUserValue fieldValue = (SPFieldUserValue)field.GetFieldValue(listUserValue);

return fieldValue.User;

}

USAGE:¬†string¬†userEmail = getUser(listItem, listItem.Fields[“Modified By”]).Email;

lly any other data like displayname etc.,

Advertisements
Read Full Post | Make a Comment ( None so far )

    About

    Xperiments n Xperiences. For the Last 5 years I have been providing variuos portal solutions (SharePoint focused) to my clients and now I intend to publish few of those solutions 'Not As It Is', which might help you. – Mash

    RSS

    Subscribe Via RSS

    • Subscribe with Bloglines
    • Add your feed to Newsburst from CNET News.com
    • Subscribe in Google Reader
    • Add to My Yahoo!
    • Subscribe in NewsGator Online
    • The latest comments to all posts in RSS

    Meta

Liked it here?
Why not try sites on the blogroll...