SPFieldLookupValue class
using System;
using Microsoft.SharePoint; namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://localhost"))
{
using (SPWeb web = site.RootWeb)
{
SPList customerList = web.Lists.TryGetList("Contoso Customers");
SPList orderList = web.Lists.TryGetList("Contoso Orders"); if (customerList != null && orderList != null)
{
SPListItemCollection customers = customerList.Items;
SPListItemCollection orders = orderList.Items; string fieldName = "CustIDLookup";
if (!orderList.Fields.ContainsField(fieldName))
return; SPField lookupFld = orderList.Fields.GetField(fieldName); foreach (SPListItem customer in customers)
{
SPListItem order = orders.Add();
order[SPBuiltInFieldId.Title] = "Thank you!";
order.Update(); SPFieldLookupValue value = new SPFieldLookupValue(customer.ID, customer.ID.ToString());
order[lookupFld.Id] = value.ToString();
order.Update();
}
}
}
}
}
}
}
SPFieldLookupValue class的更多相关文章
- SPFieldLookupValue
//得到查阅项的值SPWeb web = site.OpenWeb();SPList list = web.Lists["DemoList"];SPListItem item = ...
- 关于在Share point 2010 中保存SPFieldLookupValue类型到一个List中的问题
在share point 中,有时字段的类型是lookup的,那么将会从另外的一个list中进行相应的连接,这是如果保存string等类型,将会报一个错, Invalid data has been ...
- [SharePoint 2010] Copy list item with version history and attachment
private void MoveItem(SPListItem sourceItem, SPListItem destinationItem) { if (sourceItem == null || ...
- SharePoint 2013 列表多表联合查询
在SharePoint的企业应用中,遇到复杂的逻辑的时候,我们会需要多表查询:SharePoint和Sql数据表一样,也支持多表联合查询,但是不像Sql语句那样简单,需要使用SPQuery的Joins ...
- how to get sharepoint lookup value
SPFieldLookup lookUp1 = properties.ListItem.ParentList.Fields.GetField("Leave_x0020_Type") ...
- SharePoint 设置Lookup 字段的值
如何设置Lookup字段的值, 首先我们同样需要了解SPFieldLookupValueCollection和SPFieldLookupValue, 这2个类的原理和之前所讲解到SPFieldUser ...
- SharePoint2010 对象模型 关联列表
有关列表的创建其实网上已经有很多文章了,其中练习 :利用Visual Studio 2010创建列表这篇文章个人感觉还不错,这里我强调的是对象模型来创建.在这之前我插入一点其他的东东,导入电子表格和数 ...
- SharePoint 列表多表联合查询
在SharePoint平台二次开发中,我们有时需要涉及多表关联查询展示多列表中的不同字段信息:SharePoint和Sql数据表一样,也支持多表联合查询,但是不像Sql语句那样简单,有一定的局限性,需 ...
- SharePoint2010QuickFlow安装及使用
一:QuickFlow的安装 1,从http://quickflow.codeplex.com/下载解决方案包以及设计器. 2,将QuickFlow.dll以及QuickFlow.UI.dll添加到程 ...
随机推荐
- J.U.C-其他组件
J.U.C-其他组件 FutureTask 介绍Callable时我们知道它可以有返回值,返回值通过Future进行封装.FutrueTask实现了RunnableFuture接口,该接口继承了R ...
- PHP命名空间 namespace 及导入 use 的用法
命名空间一个最明确的目的就是解决重名问题,PHP中不允许两个函数或者类出现相同的名字,否则会产生一个致命的错误.这种情况下只要避免命名重复就可以解决,最常见的一种做法是约定一个前缀. 在PHP中,出现 ...
- springboot整合xxl-mq学习笔记
首先xxl-mq是大神xuxueli开发的一个消息中间件框架: 与springboot整合过程: <?xml version="1.0" encoding="UTF ...
- Spring 配置RMI远程调用
项目中遇到了跨系统调用,当初想的是用webservice或者是hessian.但是这个接口用到的并不多,而且是一个非常简单的方法.所有便想到了RMI.在spring中 实现RMI非常简单. 暴露服务: ...
- Linux系统lvm管理
pv: 物理卷,被pv命令处理过的物理分区vg:物理卷组 被组装到一起的物理卷pe: 物理扩展 lvm设备的最小存储单元 lvm是pe的整数倍lvm:逻辑卷 ...
- Appium——appium之mac环境安装
一.安装brew:Homebrew是一款Mac OS平台下的软件包管理工具执行:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubuserco ...
- vue快速入门(二)
工程搭建完成,接下来如何使用. 首先找到src\rooter\index.js文件 这里是路由文件配置要访问的组件,这个会在后期说明 这里的components/A 是组件里边的 需要手动 创建A.v ...
- SQL智能提示插件——SQLPrompt
1.安装SQLPrompt,直接点击下一步即可,然后打开SQL Server 在菜单栏找到SQLPrompt选项注册该软件 2.先断开网络,然后运行注册机,将注册吗复制到序列号的地方,将两个勾选的复选 ...
- oracle impdp时卡死Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
今天在用impdp导入时,Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX卡在建索引的过程一直不动,也不报错,重试了好几遍还是这样. 后来恍 ...
- python 之serial
一 先按照 pywin32:pywin32是一个非常强大的Python扩展库,是Python调用Windows系统底层功能的最佳接口,不安装这个按照pyserial也没有用 二 按装pyserial ...