您的位置:首页 > 编程语言 > C#

C# 对sharepoint 列表的一些基本操作,包括添加/删除/查询/上传文件给sharepoint list添加数据

2007-06-06 15:01 1096 查看
============================================
using Microsoft.SharePoint;

SPWeb site = SPControl.GetContextWeb(Context);
SPListItemCollection items = site.Lists["ListName"].Items;

SPListItem item = items.Add();

item["Field_1"] = OneValue;

item["Field_2"] = TwoValue;

item.Update();

删除sharepoint list数据
=============================================
using Microsoft.SharePoint;

SPWeb site = SPControl.GetContextWeb(Context);

SPListItemCollection items = site.Lists["ListName"].Items;

items[0].Delete();

上传文件到sharepoint
=============================================
using System.IO;

using Microsoft.SharePoint;

if( htmlInputFile1.PostedFile != null )

查询记录及更新数据
===============================================
using Microsoft.SharePoint;

SPWeb web = new SPSite("http://nick").OpenWeb("test"); //Open website

web.AllowUnsafeUpdates = true;

SPList list = web.Lists["ListName"];

SPQuery query = new SPQuery();

query.Query = "<Where>"+
"<And><And>"+
"<Eq><FieldRef Name=\"Filed_1\"/><Value Type=\"Text\">Test</Value></Eq>" +
"<Eq><FieldRef Name=\"Filed_2\"/><Value Type=\"Text\">" + (string)OneValue + "</Value></Eq>" +
"</And>"+
"<Eq><FieldRef Name=\"Filed_3\"/><Value Type=\"Text\">" + (string)TwoValue + "</Value></Eq>" +
"</And>"+
"</Where>";

query.RowLimit = 10;

//查询
SPListItemCollection items = list.GetItems(query);
try
catch

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1516166
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐