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的更多相关文章

  1. SPFieldLookupValue

    //得到查阅项的值SPWeb web = site.OpenWeb();SPList list = web.Lists["DemoList"];SPListItem item = ...

  2. 关于在Share point 2010 中保存SPFieldLookupValue类型到一个List中的问题

    在share point 中,有时字段的类型是lookup的,那么将会从另外的一个list中进行相应的连接,这是如果保存string等类型,将会报一个错, Invalid data has been ...

  3. [SharePoint 2010] Copy list item with version history and attachment

    private void MoveItem(SPListItem sourceItem, SPListItem destinationItem) { if (sourceItem == null || ...

  4. SharePoint 2013 列表多表联合查询

    在SharePoint的企业应用中,遇到复杂的逻辑的时候,我们会需要多表查询:SharePoint和Sql数据表一样,也支持多表联合查询,但是不像Sql语句那样简单,需要使用SPQuery的Joins ...

  5. how to get sharepoint lookup value

    SPFieldLookup lookUp1 = properties.ListItem.ParentList.Fields.GetField("Leave_x0020_Type") ...

  6. SharePoint 设置Lookup 字段的值

    如何设置Lookup字段的值, 首先我们同样需要了解SPFieldLookupValueCollection和SPFieldLookupValue, 这2个类的原理和之前所讲解到SPFieldUser ...

  7. SharePoint2010 对象模型 关联列表

    有关列表的创建其实网上已经有很多文章了,其中练习 :利用Visual Studio 2010创建列表这篇文章个人感觉还不错,这里我强调的是对象模型来创建.在这之前我插入一点其他的东东,导入电子表格和数 ...

  8. SharePoint 列表多表联合查询

    在SharePoint平台二次开发中,我们有时需要涉及多表关联查询展示多列表中的不同字段信息:SharePoint和Sql数据表一样,也支持多表联合查询,但是不像Sql语句那样简单,有一定的局限性,需 ...

  9. SharePoint2010QuickFlow安装及使用

    一:QuickFlow的安装 1,从http://quickflow.codeplex.com/下载解决方案包以及设计器. 2,将QuickFlow.dll以及QuickFlow.UI.dll添加到程 ...

随机推荐

  1. Nginx01---简单使用

    基于腾讯云--ubuntu系统 1.安装nginx sudo apt-get install nginx 2.启动,停止nginx nginx -c /usr/local/nginx/conf/ngi ...

  2. spring-redis 存储数据

    package com.fndsoft.bcis.utils; import org.springframework.beans.factory.annotation.Autowired;import ...

  3. 类关系/self/特殊成员

    1.依赖关系 在方法中引入另一个类的对象 2.关联关系.聚合关系.组合关系 #废话少说 直接上代码===>选课系统 # coding:utf-8 class Student(object): d ...

  4. [PowerShell]template engine

    今天讨论的是如何在Powershell里实现一个简单的Template Engine的功能. 假设模板文件的内容如下:template.tt hello $name welcome $company ...

  5. void类型指针的基本用法

    void作为指针时可以用任意类型的的指针值都可以给它进行赋值和传递,但是输出时必须时显性输出 代码如下: #include<cstdio> #include<iostream> ...

  6. P2913 [USACO08OCT]车轮旋转Wheel Rotation

    传送门 初始状态是 0,如果有 1 的连接,0 就变 1,如果还有 1 的连接,1 就变 0,如果是 0 的连接就不变 所以就是把答案异或上所有连接,不用考虑顺序,反正最终是一样的 #include& ...

  7. 17.JavaMail

    1.电子邮件 电子邮件是目前网络上使用最多的服务,电子邮件的应用越来越广泛正常的通信往来账号注册时,找回密码时等一般发送的邮件主要可以分解成2大部分一部分是发信人.接信人.主题等邮件标头另外一部分是邮 ...

  8. Vi编辑器和Vim编辑器的区别及联系

    Vi和Vim它们都是多模式编辑器,不同的是vim 是vi的升级版本,它不仅兼容vi的所有指令,而且还有一些新的特性在里面,vi使用于文本编辑,但是vim更适用于coding.vim的这些优势主要体现在 ...

  9. python__画图表可参考(转自:寒小阳 逻辑回归应用之Kaggle泰坦尼克之灾)

    出处:http://blog.csdn.net/han_xiaoyang/article/details/49797143 2.背景 2.1 关于Kaggle 我是Kaggle地址,翻我牌子 亲,逼格 ...

  10. appium连接夜神模拟器方法总结

    使用appium连接模拟器前提条件:appium环境已经搭建完毕,搭建步骤请参考我的博客:appium手机自动化环境搭建 1.下载并安装夜神模拟器:https://www.yeshen.com/ 2. ...