SharePoint - 无需手动解析即可获取计算字段的值 [英] SharePoint - get value of calculated field without manual parsing
本文介绍了SharePoint - 无需手动解析即可获取计算字段的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在列表中有一个计算字段,其中包含以下公式:
<代码>=CID &"- " &标题
I have a calculated field in a list with this formula:
=CID & " - " & Title
查看列表时,它可能显示为:2 - 大型会议".当我像这样从代码中获取值时:myItem["CIDandTitle"]
When viewing the list, it might display as: "2 - Big Meeting". When I grab the value from code like so:
myItem["CIDandTitle"]
该值返回为:字符串;#2 - BigMeeting".sharepoint 中是否有正确"的方法来提取值,还是应该简单地在分号和井号上拆分?
the value comes back as: "string;#2 - BigMeeting". Is there a "correct" way in sharepoint to extract the value or should i simply split on the semicolon and pound sign?
我使用的是 MOSS2007.
I am using MOSS2007.
推荐答案
您必须将其强制转换为 SPCalculatedField:
You have to cast it to an SPCalculatedField:
SPFieldCalculated cf = (SPFieldCalculated)myItem.Fields["CIDandTitle"];
string value = cf.GetFieldValueForEdit(myItem["CIDandTitle"]);
或
string value = cf.GetFieldValueAsText(myItem["CIDandTitle"]);
这篇关于SharePoint - 无需手动解析即可获取计算字段的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文