How to Retrieve the SPUSer Valuesfrom people finder control .
The following function can be used to retrieve the user name and other properties from people finder controls.
There are two classes used here
1. SPFieldUser -- Gets the field or column onformation
2. SPFieldUserValue- -Gets the values from SPUSERFIELD
and here is the code ... enjoy....
private SPUser GetSPUserNameFromIDEmailGAP(SPList GAPList, SPListItem ObjGroupAuditInformation)
{
try
{
SPUser user = null;
if (GAPList != null)
{
//gets the column name
SPFieldUser userField = (SPFieldUser)GAPList.Fields["ColumnName"];
//gets the value of spuser
SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(Convert.ToString(ObjGroupAuditInformation["Column name"];
if (fieldValue.User != null)
{
user = fieldValue.User; // you can have all other properties such as fieldvalue.email etc)
}
}
return user;
}
catch (Exception ex)
{
return null;
}
}
The following function can be used to retrieve the user name and other properties from people finder controls.
There are two classes used here
1. SPFieldUser -- Gets the field or column onformation
2. SPFieldUserValue- -Gets the values from SPUSERFIELD
and here is the code ... enjoy....
private SPUser GetSPUserNameFromIDEmailGAP(SPList GAPList, SPListItem ObjGroupAuditInformation)
{
try
{
SPUser user = null;
if (GAPList != null)
{
//gets the column name
SPFieldUser userField = (SPFieldUser)GAPList.Fields["ColumnName"];
//gets the value of spuser
SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(Convert.ToString(ObjGroupAuditInformation["Column name"];
if (fieldValue.User != null)
{
user = fieldValue.User; // you can have all other properties such as fieldvalue.email etc)
}
}
return user;
}
catch (Exception ex)
{
return null;
}
}
No comments:
Post a Comment