2012-10-10 32 views
0

內下面的代碼段返回下面的錯誤不知道哪裏出了問題,SPFieldUserValue:值沒有在預期的範圍

異常詳細信息:System.ArgumentException:值沒有在預期的範圍內。

public static SPUser convertStringToSPUser(string struser) 
{ 
    SPFieldUserValue userValue = new SPFieldUserValue(SPContext.Current.Web, struser); 
    SPUser objSPUser = userValue.User; 
    return objSPUser; 
} 

我的字符串是一樣的東西, 「S,仙人」。

回答

4

爲了營造SPFieldUserValue的情況下,你應該通過以下格式的字符串: [INT]#[域] \ [用戶名]

最簡單的方式來獲得一個列表項的值是: ListItem [field_GUID] .ToString();

相關問題