I have a people picker field in my custom web part and when the user fills the data and submits it i want this value to be populated in a share point list .following is the code i am using and this is giving me a error "The specified user not found" Can you please help me with this . Also i tested for other fields and those are populating without any error only this filed is giving me error..
SPWeb app = SPContext.Current.Web;
SPList ListName = app.Lists["Communities Directory"];
SPListItem ListItem = ListName.Items.Add();
string[] UsersSeperated = pickAdministrators.CommaSeparatedAccounts.Split(',');
SPFieldUserValueCollection UserCollection = new SPFieldUserValueCollection();
foreach (string UserSeperated in UsersSeperated)
{
app.EnsureUser(UserSeperated);
SPUser User = app.SiteUsers[UserSeperated];
SPFieldUserValue UserName = new SPFieldUserValue(app, User.ID, User.LoginName);
UserCollection.Add(UserName);
}
ListItem["Contact Person"] = UserCollection;