Question

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.

Was it helpful?

Solution

Try:

SPFieldUserValue userValue = new SPFieldUserValue(web, item["Created By"].ToString());
string Author = userValue.LookupValue;
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top