WSS V3 - SPListItem["Assigned To"] returns special character (#)  
Author Message
Sriram Rajamanuri





PostPosted: SharePoint - Development and Programming, WSS V3 - SPListItem["Assigned To"] returns special character (#) Top

Hi,

I am trying to retrieve a value from a listitem and it is returning the desired value (name) preceded with three additional characters.. Any idea why it is happening.

ex:

SPListItem objItem;

string strName = objItem["Assigned To"

Thanks




SharePoint Products and Technologies2  
 
 
Ishai Sagi





PostPosted: SharePoint - Development and Programming, WSS V3 - SPListItem["Assigned To"] returns special character (#) Top

You need to use the SPFieldUserValue object.

example:

private SPUser GetUser(SPListItem item, SPField userField)
{

string currentValue = item[userField.Title].ToString();
SPFieldUser field = (SPFieldUser) userField;
SPFieldUserValue fieldValue = (SPFieldUserValue)field.GetFieldValue(currentValue);
return fieldValue.User;

}

usage:

string strName = GetUser(objItem,objItem.Fields["Assigned To"]).Name;