Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Created By Field Returns the following:

1073741823;#System Account

I want the following without string manipulation (i.e. without using substring to remove all of the characters before ";#"):

System Account

How can I do the above programmatically in a visual webpart?

string Author = item["Created By"].ToString(); 

The above is what I am currently using to get the author, but I want the login name to be the author

Any ideas on how I can achieve this?

I am fairly new to SharePoint and could really use the assistance.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Try:

SPFieldUserValue userValue = new SPFieldUserValue(web, item["Created By"].ToString());
string Author = userValue.LookupValue;
share|improve this answer
    
OMG THAT WORKED +1!!! I'll accept your answer when I'm allowed to. Thank you so much! –  MyName Mar 14 '12 at 14:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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