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. 勤哲Excel服务器人力资源管理系统

    “一个和尚挑水吃,两个和尚抬水吃,三个和尚没水吃!”,这则古老寓言之于现代企业管理而言,相当有意义.在现代企业管理中,类似三个和尚没水吃的管理难题是普遍存在的.如何有效破解?还是得从管理下手,从建立管 ...

  2. AdvancedEncryptionStandard

    import java.security.GeneralSecurityException; import javax.crypto.Cipher; import javax.crypto.spec. ...

  3. thinkphp自动验证和自动完成

    tp验证码的自动验证小案例 模板文件 <form action="" method="post"> <p> User: <inpu ...

  4. my13_mysql xtrabackup备份的时间点

    备份原理 xtrabackup的备份时间点是备份结束时刻,记录在xtrabackup_binlog_info 文件中:如果后续需要通过binlog追加操作,则该时间点是起点. 备份开始后,xtrabc ...

  5. va_list arg_list va_start(arg_list, format) va_end( arg_list ) 原理的理解

    void log( int log_level, const char* file_name, int line_num, const char* format, ... ) { .......... ...

  6. linux进程间的通信之 共享内存

    一.共享内存介绍 共享内存是三个IPC(Inter-Process Communication)机制中的一个. 它允许两个不相关的进程访问同一个逻辑内存. 共享内存是在两个正在进行的进程之间传递数据的 ...

  7. 3d Max 2015安装失败怎样卸载3dsmax?错误提示某些产品无法安装

    AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...

  8. Linux的cron服务

    可以用以下命令启动和停止服务: /sbin/service crond start /sbin/service crond stop /sbin/service crond restart /sbin ...

  9. 搭建mysql集群,使用Percona XtraDB Cluster搭建

    Percona XtraDB Cluster提供的特性有:1.同步复制,事务要么在所有节点提交或不提交.2.多主复制,可以在任意节点进行写操作.3.在从服务器上并行应用事件,真正意义上的并行复制.4. ...

  10. Python实现抓取CSDN热门文章列表

    1.使用工具: Python3.5 BeautifulSoup 2.抓取网站: csdn热门文章列表 http://blog.csdn.net/hot.html 3.分析网站代码: 4.实现代码: _ ...