深入浅出SharePoint——获取Choice Field的Mapping value
2014-09-25 09:17
225 查看
list field对应的caml定义如下
Console应用程序:
读取第一个item中choice单选类型的field的value值
list field对应的caml定义如下
<Field Type="Choice" DisplayName="Inspection Result" Required="FALSE" Format="RadioButtons" FillInChoice="FALSE" Group="C0370A" ID="{5D00E04C-9BA6-4f78-BC51-2D2EC2C2EC73}" SourceID="{1e228f79-b273-49cd-b9cc-507b1ecc7c5c}" StaticName="VPPI_InspectionResult" Name="VPPI_InspectionResult" > <CHOICES> <CHOICE>Satisfactory</CHOICE> <CHOICE>Unsatisfactory – but no assistance is needed</CHOICE> <CHOICE>Unsatisfactory – I need assistance</CHOICE> </CHOICES> <MAPPINGS> <MAPPING Value="1">Satisfactory</MAPPING> <MAPPING Value="2">Unsatisfactory – but no assistance is needed</MAPPING> <MAPPING Value="3">Unsatisfactory – I need assistance</MAPPING> </MAPPINGS> </Field>
Console应用程序:
读取第一个item中choice单选类型的field的value值
class Program { static void Main(string[] args) { using (SPSite site = new SPSite("http://cris-moss/sites/EHS")) { using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists["Safety Inspection Verification"]; if (list != null) { SPListItem item = list.Items[0]; SPFieldChoice chVisiblity = (SPFieldChoice)item.Fields.GetField("VPPI_InspectionResult"); object value = item["VPPI_InspectionResult"]; string selectedText = chVisiblity.GetFieldValueAsText(item["VPPI_InspectionResult"]); Console.WriteLine("The value of the field is {0}, which means '{1}'.", value.ToString(), GetMappingValueforSPFieldChoice(selectedText,chVisiblity.Mappings)); } Console.ReadLine(); } } } static string GetMappingValueforSPFieldChoice(string selectedText,string mappings) { string selectedValue = string.Empty; XmlDocument doc=new XmlDocument(); doc.LoadXml(mappings); XmlNode node = doc.SelectSingleNode("MAPPINGS/MAPPING[text()='" + selectedText + "']"); selectedValue = node.Attributes["Value"].Value; return selectedValue; } }
相关文章推荐
- 深入浅出SharePoint——获取Choice Field的Mapping value
- 深入浅出InfoPath——获取SharePoint群组中用户(无代码)
- 深入浅出InfoPath——获取SharePoint群组中用户(无代码)
- SharePoint 2007 Choice Field 不能更新
- 深入浅出SharePoint——利用jQuery访问SharePoint Web Service获取用户信息
- [SharePoint]javascript client object model 获取lookup 类型的field的值,包括user类型(单人或者多人)的值。how to get the multiple user type/lookup type field value by Javascript client object model
- 深入浅出InfoPath——获取SharePoint群组中用户(无代码)
- 深入浅出SharePoint2013——获取Application Pool的id和name对照表
- sharepoint获取Audiences
- SharePoint对象模式获取“用户或用户组”栏的值
- sharepoint使用自定义RSS webpart获取weather天气、stock股票信息
- 深入浅出SharePoint——数据库维护
- 获取GridView中TemplatedField中LinkButton命令的当前行
- 用Javascript获取SharePoint当前登录用户的用户名及Group信息
- 深入浅出SharePoint——在wss3.0中不能在数据表视图中进行编辑
- 获取GridView的TemplateField模版中某列值
- 如何将sharepoint列表中choice类型的值绑定到dropdownlist上
- SharePoint对象模式获取“用户或用户组”栏的值
- SharePoint开发获取文档库信息
- 获取&修改SharePoint站点中的任意WebPart