2013-02-09 71 views
-1

我有一組代碼,它返回一個值「2; #bbbb」,因爲我想實現bbbb。 下面是我寫的代碼。 SPListItemCollection col = StationaryList.Items;對於(int i = 0; i < col.Count; i ++) { SPListItem item = col [i]; categoryName = item [「QuizCategoryName」]。ToString(); }從字符串c提取子字符串#

Please tell me what do i do to achieve this. 
Actual Output: "2;#bbbb" 
Expected Output: bbbb 

回答

0
string str = categoryName; 
string[] result = str.Split('#'); 
if(result.Length > 1) 
Response.Write(result[1]); // your expected output 
0

這是查找字段的格式,它可以用下sintaxys提取:

SPFieldLookupValue f = new SPFieldLookupValue("your text here"); 
string value = f.LookupValue; 

這樣可以提取ID而你的情況是2

安德魯