-1

我有一组代码返回一个值“2;#bbbb”,因为我想实现 bbbb。下面是我写的代码。SPListItemCollection col = StationaryList.Items;for (int i = 0; i < col.Count; i++) { SPListItem item = col[i]; categoryName=item["QuizCategoryName"].ToString(); }

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

2 回答 2

0
string str = categoryName;
string[] result = str.Split('#');
if(result.Length > 1)
Response.Write(result[1]); // your expected output
于 2013-02-09T11:04:21.190 回答
0

这是可以使用下一个 sintaxys 提取的查找字段的格式:

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

这种方式可以提取ID,在你的情况下是2

安德鲁

于 2013-02-09T22:06:42.310 回答