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添加到程 ...
随机推荐
- kuangbin专题十六 KMP&&扩展KMP HDU2594 Simpsons’ Hidden Talents
Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had. Marg ...
- centos操作---搭建环境 安装python
1.安装python3.6.2 安装依赖 yum -y groupinstall "Development tools" yum -y install zlib-devel bzi ...
- anglarJs分页
首先在页面引入分页插件 <script src="../plugins/angularjs/pagination.js"></script> <lin ...
- POJ1056 IMMEDIATE DECODABILITY & POJ3630 Phone List
题目来源:http://poj.org/problem?id=1056 http://poj.org/problem?id=3630 两题非常类似,所以在这里一并做了. 1056题目大意: 如果一 ...
- java中\r ,\n,\t等的含义
\t 相当于tab,缩进,制表符\n NewLine 换行 \f 换页符 \r 回车 \" 转义 “\\ 转义 \
- linux 底层 基础命令 路径信息
z基础命令: 打印 :echo "hello world“ 切换目录 cd / 显示当前路径 pwd 显示 目录下所有文件 ls 显示所有文件包括隐藏文件 ls ...
- IP地址概念
1.1 IP地址概念 什么是IP地址:由32位二进制数组成,划分成4组,每组八位: 为了便于人类识别记忆,IP地址表现形式为 "点分十进制" 二进制数与十进制数的转换关系:00 ...
- Linux 系统排错
##root用户密码的修改 重启时按上下键打断引导,按“e”进入内核引导 在linux16行删除至途中所示位置,并进行修改: 修改完毕后按“ctrl+x”启动 进入系统切换到真实环境,开始修改root ...
- 风险识别工具 - 影响图(Influence Diagram)
原文地址:http://blog.csdn.net/jameszhou/archive/2007/06/24/1664494.aspx PMBOK(2004 3rd 英) P248关于风险识别的图形技 ...
- Linux 磁盘管理基础命令df,du,fdisk,mke2fs
1.df:查看已挂载磁盘的总容量,使用容量和剩余容量等,默认以KB位单位显示 文件系统 容量 已用 可用 已用百分比 挂载点 df常用选项-i,-h,-k,-m ...