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.



SPFieldUserValue userValue = new SPFieldUserValue(web, item["Created By"].ToString());
string Author = userValue.LookupValue;

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.